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

Side by Side Diff: Doc/library/imaplib.rst

Issue 4972: context managerment support in imaplib, smtplib, ftplib
Patch Set: Created 5 years, 7 months ago
Left:
Right:
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 unified diff | Download patch
« no previous file with comments | « no previous file | Doc/whatsnew/3.5.rst » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 :mod:`imaplib` --- IMAP4 protocol client 1 :mod:`imaplib` --- IMAP4 protocol client
2 ======================================== 2 ========================================
3 3
4 .. module:: imaplib 4 .. module:: imaplib
5 :synopsis: IMAP4 protocol client (requires sockets). 5 :synopsis: IMAP4 protocol client (requires sockets).
6 .. moduleauthor:: Piers Lauder <piers@communitysolutions.com.au> 6 .. moduleauthor:: Piers Lauder <piers@communitysolutions.com.au>
7 .. sectionauthor:: Piers Lauder <piers@communitysolutions.com.au> 7 .. sectionauthor:: Piers Lauder <piers@communitysolutions.com.au>
8 .. revised by ESR, January 2000 8 .. revised by ESR, January 2000
9 .. changes for IMAP4_SSL by Tino Lange <Tino.Lange@isg.de>, March 2002 9 .. changes for IMAP4_SSL by Tino Lange <Tino.Lange@isg.de>, March 2002
10 .. changes for IMAP4_stream by Piers Lauder <piers@communitysolutions.com.au>, 10 .. changes for IMAP4_stream by Piers Lauder <piers@communitysolutions.com.au>,
(...skipping 18 matching lines...) Expand all
29 Three classes are provided by the :mod:`imaplib` module, :class:`IMAP4` is the 29 Three classes are provided by the :mod:`imaplib` module, :class:`IMAP4` is the
30 base class: 30 base class:
31 31
32 32
33 .. class:: IMAP4(host='', port=IMAP4_PORT) 33 .. class:: IMAP4(host='', port=IMAP4_PORT)
34 34
35 This class implements the actual IMAP4 protocol. The connection is created a nd 35 This class implements the actual IMAP4 protocol. The connection is created a nd
36 protocol version (IMAP4 or IMAP4rev1) is determined when the instance is 36 protocol version (IMAP4 or IMAP4rev1) is determined when the instance is
37 initialized. If *host* is not specified, ``''`` (the local host) is used. If 37 initialized. If *host* is not specified, ``''`` (the local host) is used. If
38 *port* is omitted, the standard IMAP4 port (143) is used. 38 *port* is omitted, the standard IMAP4 port (143) is used.
39
40 The :class:`IMAP4` class supports the :keyword:`with` statement. When used
41 like this, the IMAP4 ``LOGOUT`` command is issued automatically when the
42 :keyword:`with` statement exits. E.g.::
43
44 >>> from imaplib import IMAP4
45 >>> with IMAP4("domain.org") as imap:
46 ... imap.noop()
47 ...
48 ('OK', [b'Nothing Accomplished. d25if65hy903weo.87'])
49
50 .. versionchanged:: 3.5
51 Support for the :keyword:`with` statement was added.
39 52
40 Three exceptions are defined as attributes of the :class:`IMAP4` class: 53 Three exceptions are defined as attributes of the :class:`IMAP4` class:
41 54
42 55
43 .. exception:: IMAP4.error 56 .. exception:: IMAP4.error
44 57
45 Exception raised on any errors. The reason for the exception is passed to th e 58 Exception raised on any errors. The reason for the exception is passed to th e
46 constructor as a string. 59 constructor as a string.
47 60
48 61
(...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 M = imaplib.IMAP4() 555 M = imaplib.IMAP4()
543 M.login(getpass.getuser(), getpass.getpass()) 556 M.login(getpass.getuser(), getpass.getpass())
544 M.select() 557 M.select()
545 typ, data = M.search(None, 'ALL') 558 typ, data = M.search(None, 'ALL')
546 for num in data[0].split(): 559 for num in data[0].split():
547 typ, data = M.fetch(num, '(RFC822)') 560 typ, data = M.fetch(num, '(RFC822)')
548 print('Message %s\n%s\n' % (num, data[0][1])) 561 print('Message %s\n%s\n' % (num, data[0][1]))
549 M.close() 562 M.close()
550 M.logout() 563 M.logout()
551 564
OLDNEW
« 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+