summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorScott Maxwell <scott@codecobblers.com>2013-11-19 08:56:53 -0800
committerScott Maxwell <scott@codecobblers.com>2013-11-19 08:56:53 -0800
commit2da5f1fb4565d1e6dc72672f640dac44b122d235 (patch)
tree341373c292485f1417933551cc5c425d17fbbd44 /demos
parent7471515fffd2315f7330c5e1dd42f353982ded6c (diff)
downloadparamiko-2da5f1fb4565d1e6dc72672f640dac44b122d235.tar.gz
Use 'with' for opening most file and SFTPFIle objects
Diffstat (limited to 'demos')
-rwxr-xr-xdemos/demo_sftp.py3
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)