We have all sorts of useful snippets in our extension, but I've noticed that we have not added one for the ubiquitous block:
if __name__ == '__main__':
Proposal to add the snippet with the type-ahead identifier __main__.
Acceptance Criteria:
- Open a new editor window
- Create a new file
helloworld.py
- Add the following code:
1| import sys
2|
3| def hello_world():
4| print('Hi there!')
5| print(f'Python version {sys.version_info}')
6|
7|
- On line 7, begin type
__main
Expected Result
Popup with a snippet for the dunder name equals dunder main appears. Pressing Enter will accept the snippet and insert code such as:
6|
7| if __name__ == '__main__':
8| $
9|
...where the $ is where the cursor is left such that the user can add whatever call(s) are necessary.
EDIT: Acceptance criteria altered to ensure cursor is placed optimally.
We have all sorts of useful snippets in our extension, but I've noticed that we have not added one for the ubiquitous block:
if __name__ == '__main__':Proposal to add the snippet with the type-ahead identifier
__main__.Acceptance Criteria:
helloworld.py__mainExpected Result
Popup with a snippet for the dunder name equals dunder main appears. Pressing
Enterwill accept the snippet and insert code such as:...where the
$is where the cursor is left such that the user can add whatever call(s) are necessary.