Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1)

Unified Diff: Doc/library/imaplib.rst

Issue 4972: context managerment support in imaplib, smtplib, ftplib
Patch Set: Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Doc/whatsnew/3.5.rst » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
--- a/Doc/library/imaplib.rst
+++ b/Doc/library/imaplib.rst
@@ -32,16 +32,29 @@ base class:
.. class:: IMAP4(host='', port=IMAP4_PORT)
This class implements the actual IMAP4 protocol. The connection is created and
protocol version (IMAP4 or IMAP4rev1) is determined when the instance is
initialized. If *host* is not specified, ``''`` (the local host) is used. If
*port* is omitted, the standard IMAP4 port (143) is used.
+ The :class:`IMAP4` class supports the :keyword:`with` statement. When used
+ like this, the IMAP4 ``LOGOUT`` command is issued automatically when the
+ :keyword:`with` statement exits. E.g.::
+
+ >>> from imaplib import IMAP4
+ >>> with IMAP4("domain.org") as imap:
+ ... imap.noop()
+ ...
+ ('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])
+
+ .. versionchanged:: 3.5
+ Support for the :keyword:`with` statement was added.
+
Three exceptions are defined as attributes of the :class:`IMAP4` class:
.. exception:: IMAP4.error
Exception raised on any errors. The reason for the exception is passed to the
constructor as a string.
« no previous file with comments | « no previous file | Doc/whatsnew/3.5.rst » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+