diff options
author | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 08:56:53 -0800 |
---|---|---|
committer | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 09:38:05 -0800 |
commit | 106f9ea444ee9ed8246be128f232217b6c4977b8 (patch) | |
tree | fc995d404aaee9b3c48d5604e32e63725215d8e1 /demos/demo_sftp.py | |
parent | 2da5f1fb4565d1e6dc72672f640dac44b122d235 (diff) |
Use 'with' for opening most file and SFTPFIle objects
Diffstat (limited to 'demos/demo_sftp.py')
-rwxr-xr-x | demos/demo_sftp.py | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/demos/demo_sftp.py b/demos/demo_sftp.py index 9476f76c..c04d6e15 100755 --- a/demos/demo_sftp.py +++ b/demos/demo_sftp.py @@ -104,7 +104,8 @@ try: print('created demo_sftp_folder/ on the server') # copy the README back here - data = sftp.open('demo_sftp_folder/README', 'r').read() + with sftp.open('demo_sftp_folder/README', 'r') as f: + data = f.read() with open('README_demo_sftp', 'w') as f: f.write(data) print('copied README back here') |