Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions snippets/python_snippets.json
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,8 @@
"built_in.open=>": {
"prefix": "built_in.open=>",
"body": [
"f = open('demofile.txt', 'r')",
"print(f.read())"
"with open('demofile.txt', 'r') as f:",
" print(f.read())"
],
"description": "An example for using open"
},
Expand Down Expand Up @@ -3508,32 +3508,32 @@
"openFile": {
"prefix": "file=>openFile",
"body": [
"f = open('demofile.txt', 'r')",
"print(f.read())"
"with open('demofile.txt', 'r') as f:",
" print(f.read())"
],
"description": "open a file"
},
"openFileReadLine": {
"prefix": "file=>openFileReadLine",
"body": [
"f = open('demofile.txt', 'r')",
"print(f.readline())"
"with open('demofile.txt', 'r') as f:",
" print(f.readline())"
],
"description": "Read one line of the file"
},
"writeExistFile": {
"prefix": "file=>writeExistFile",
"body": [
"f = open('demofile.txt', 'a')",
"f.write('Now the file has one more line!')"
"with open('demofile.txt', 'a') as f:",
" f.write('Now the file has one more line!')"
],
"description": "Write to an Existing File"
},
"writeOwerWrite": {
"prefix": "file=>writeOwerWrite",
"body": [
"f = open('demofile.txt', 'w')",
"f.write('Woops! I have deleted the content!')"
"with open('demofile.txt', 'w') as f:",
" f.write('Woops! I have deleted the content!')"
],
"description": "Open a file and overwrite the content"
},
Expand Down