]> granicus.if.org Git - python/commitdiff
Doc: Use the `with` statement in the first example of the ftplib doc. (GH-16271)...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Thu, 26 Sep 2019 07:12:39 +0000 (00:12 -0700)
committerStéphane Wirtel <stephane@wirtel.be>
Thu, 26 Sep 2019 07:12:39 +0000 (09:12 +0200)
(cherry picked from commit 5d326abf2cb4891b78d9319a81bffb3974b5b745)

Co-authored-by: Stéphane Wirtel <stephane@wirtel.be>
Doc/library/ftplib.rst

index 7423413d209ae0f67f95907372e1f4dfad136775..db0212367340d9bd56004594a011cfbb554b167f 100644 (file)
@@ -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-xr-x    3 1176     1176         4096 Oct 10  2012 tools
    '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.'
    >>> ftp.quit()