diff options
author | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 08:56:53 -0800 |
---|---|---|
committer | Scott Maxwell <scott@codecobblers.com> | 2013-11-19 08:56:53 -0800 |
commit | 2da5f1fb4565d1e6dc72672f640dac44b122d235 (patch) | |
tree | 341373c292485f1417933551cc5c425d17fbbd44 /demos/demo_sftp.py | |
parent | 7471515fffd2315f7330c5e1dd42f353982ded6c (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 1cccffc2..9476f76c 100755 --- a/demos/demo_sftp.py +++ b/demos/demo_sftp.py @@ -96,7 +96,8 @@ try: sftp.mkdir("demo_sftp_folder") except IOError: print('(assuming demo_sftp_folder/ already exists)') - sftp.open('demo_sftp_folder/README', 'w').write('This was created by demo_sftp.py.\n') + with sftp.open('demo_sftp_folder/README', 'w') as f: + f.write('This was created by demo_sftp.py.\n') with open('demo_sftp.py', 'r') as f: data = f.read() sftp.open('demo_sftp_folder/demo_sftp.py', 'w').write(data) |