Commit 5d326abf authored by Stéphane Wirtel's avatar Stéphane Wirtel Committed by GitHub

Doc: Use the `with` statement in the first example of the ftplib doc. (GH-16271)

parent 8e7bb991
...@@ -33,7 +33,8 @@ Here's a sample session using the :mod:`ftplib` module:: ...@@ -33,7 +33,8 @@ Here's a sample session using the :mod:`ftplib` module::
drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project drwxr-sr-x 4 1176 1176 4096 Nov 17 2008 project
drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools drwxr-xr-x 3 1176 1176 4096 Oct 10 2012 tools
'226 Directory send OK.' '226 Directory send OK.'
>>> ftp.retrbinary('RETR README', open('README', 'wb').write) >>> with open('README', 'wb') as fp:
>>> ftp.retrbinary('RETR README', fp.write)
'226 Transfer complete.' '226 Transfer complete.'
>>> ftp.quit() >>> ftp.quit()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment