Created
September 3, 2024 00:23
-
-
Save joelhoro/b03f595b5de1cc209c4c0aef8ee51c07 to your computer and use it in GitHub Desktop.
Python snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
// Place your snippets for python here. Each snippet is defined under a snippet name and has a prefix, body and | |
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are: | |
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the | |
// same ids are connected. | |
// Example: | |
"Set pandas options": { | |
"prefix": "pdoptions", | |
"body": [ | |
"import pandas as pd" | |
"pd.set_option(\"display.max_columns\", None)" | |
"pd.set_option(\"display.max_rows\", None)" | |
], | |
"description": "Pandas shortcuts" | |
}, | |
"Pandas sample dataframe": { | |
"prefix": "pdsample", | |
"body": [ | |
"import pandas as pd" | |
"${1:df} = pd.read_csv(\"http://bit.ly/kaggletrain\")" | |
], | |
"description": "Pandas sample" | |
}, | |
"Open file": { | |
"prefix": "openfile", | |
"body": [ | |
"with open(\"${1:file.txt}\", \"${2:r}\") as f:" | |
" ${3:content} = f.read()" | |
], | |
"description": "Open file" | |
}, | |
"Create async iterator": { | |
"prefix": "aiter", | |
"body": [ | |
"from typing import AsyncIterator" | |
"async def ${1:aiter}() -> AsyncIterator[$2]:" | |
" for ${3:item} in ${4:iterable}:" | |
" yield ${5:item}" | |
], | |
"description": "Create async iterator" | |
}, | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment