Skip to content

Commit 942f544

Browse files
rsnk96brettcannon
authored andcommitted
Add snippet for if __name__ == "__main__": block (microsoft#2881)
1 parent f30eb73 commit 942f544

File tree

2 files changed

+6
-7
lines changed

2 files changed

+6
-7
lines changed

news/1 Enhancements/2242.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Add a new simple snippet for `if __name__ == '__main__':` block. The snippet can be accessed by typing `__main__`
2+
(thanks [R S Nikhil Krishna](https://github.com/rsnk96/))

snippets/python.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,12 @@
184184
"description": "Code snippet for a lambda statement"
185185
},
186186
"if(main)": {
187-
"prefix": "if(main)",
187+
"prefix": "__main__",
188188
"body": [
189-
"def main():",
190-
"\t${1:pass}",
191-
"",
192-
"if __name__ == '__main__':",
193-
"\tmain()"
189+
"if __name__ == \"__main__\":",
190+
" ${1:pass}",
194191
],
195-
"description": "Code snippet for a main function"
192+
"description": "Code snippet for a `if __name__ == \"__main__\": ...` block"
196193
},
197194
"async/def": {
198195
"prefix": "async/def",

0 commit comments

Comments
 (0)