diff options
author | Giampaolo Rodolà <g.rodola@gmail.com> | 2010-05-10 14:53:29 (GMT) |
---|---|---|
committer | Giampaolo Rodolà <g.rodola@gmail.com> | 2010-05-10 14:53:29 (GMT) |
commit | bd576b75b7bed253b7bf4af5a967e3ee4dc1af8a (patch) | |
tree | fe5924f78b230670672d6097bc3be6724fed9b27 /Doc | |
parent | f95a1b3c53bdd678b64aa608d4375660033460c3 (diff) | |
download | cpython-bd576b75b7bed253b7bf4af5a967e3ee4dc1af8a.zip cpython-bd576b75b7bed253b7bf4af5a967e3ee4dc1af8a.tar.gz cpython-bd576b75b7bed253b7bf4af5a967e3ee4dc1af8a.tar.bz2 |
Fix issue #4972: adds ftplib.FTP context manager protocol
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/ftplib.rst | 19 | ||||
-rw-r--r-- | Doc/whatsnew/3.2.rst | 3 |
2 files changed, 22 insertions, 0 deletions
diff --git a/Doc/library/ftplib.rst b/Doc/library/ftplib.rst index 02edef7..857f413 100644 --- a/Doc/library/ftplib.rst +++ b/Doc/library/ftplib.rst @@ -46,6 +46,25 @@ The module defines the following items: connection attempt (if is not specified, the global default timeout setting will be used). + :class:`FTP` class supports the :keyword:`with` statement. Here is a sample + on how using it: + + >>> from ftplib import FTP + >>> with FTP("ftp1.at.proftpd.org") as ftp: + ... ftp.login() + ... ftp.dir() + ... + '230 Anonymous login ok, restrictions apply.' + dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 . + dr-xr-xr-x 9 ftp ftp 154 May 6 10:43 .. + dr-xr-xr-x 5 ftp ftp 4096 May 6 10:43 CentOS + dr-xr-xr-x 3 ftp ftp 18 Jul 10 2008 Fedora + >>> + + .. versionchanged:: 3.2 + Support for the :keyword:`with` statement was added. + + .. class:: FTP_TLS(host='', user='', passwd='', acct='', [keyfile[, certfile[, timeout]]]) A :class:`FTP` subclass which adds TLS support to FTP as described in diff --git a/Doc/whatsnew/3.2.rst b/Doc/whatsnew/3.2.rst index 877283b..e61ad44 100644 --- a/Doc/whatsnew/3.2.rst +++ b/Doc/whatsnew/3.2.rst @@ -66,6 +66,9 @@ Some smaller changes made to the core Python language are: New, Improved, and Deprecated Modules ===================================== +* The :class:`ftplib.FTP` class now supports the context manager protocol + (Contributed by Tarek Ziadé and Giampaolo Rodolà; :issue:`4972`.) + * The previously deprecated :func:`string.maketrans` function has been removed in favor of the static methods, :meth:`bytes.maketrans` and :meth:`bytearray.maketrans`. This change solves the confusion around which |