Skip to content

Instantly share code, notes, and snippets.

@timlau
Last active January 20, 2023 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timlau/4b81a20ea69078a0abbb2d57d32c4449 to your computer and use it in GitHub Desktop.
Save timlau/4b81a20ea69078a0abbb2d57d32c4449 to your computer and use it in GitHub Desktop.
VS Code Python snippets
{
"main function": {
"prefix": [
"def main",
"if __name__"
],
"body": [
"def main() -> None:",
" print(\"Hello World!\")",
"",
"if __name__ == \"__main__\":",
" main()",
"",
"$0"
],
"description": "insert main function"
},
"define function": {
"prefix": "def",
"body": [
"def $1($2):",
" $0"
],
"description": "create a new function"
},
"define function with type": {
"prefix": [
"def",
"function"
],
"body": [
"def ${1:function_name}(${2:*args, **kwargs}) -> ${3:None}:",
" ${4:pass}$0"
],
"description": "create a new function"
},
"define method with type": {
"prefix": [
"def",
"method"
],
"body": [
"def ${1:function_name}(self, ${2:*args, **kwargs}) -> ${3:None}:",
" ${4:pass}$0"
],
"description": "create a new class method"
},
"define property": {
"prefix": [
"property"
],
"body": [
"@property",
"def ${1:function_name}(self):",
" return ${2:self.}$0"
],
"description": "create a new class property"
},
"define class": {
"prefix": [
"class"
],
"body": [
"class ${1:ClassName}:",
"",
" def __init__(self, ${2:parameters}) -> None:",
" $0",
"",
""
],
"description": "create a new class"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment