Last active
January 20, 2023 13:59
-
-
Save timlau/4b81a20ea69078a0abbb2d57d32c4449 to your computer and use it in GitHub Desktop.
VS Code Python snippets
This file contains 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
{ | |
"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