doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
class email.mime.nonmultipart.MIMENonMultipart Module: email.mime.nonmultipart A subclass of MIMEBase, this is an intermediate base class for MIME messages that are not multipart. The primary purpose of this class is to prevent the use of the attach() method, which only makes sense for multipart messages. If attach()...
python.library.email.mime#email.mime.nonmultipart.MIMENonMultipart
class email.mime.text.MIMEText(_text, _subtype='plain', _charset=None, *, policy=compat32) Module: email.mime.text A subclass of MIMENonMultipart, the MIMEText class is used to create MIME objects of major type text. _text is the string for the payload. _subtype is the minor type and defaults to plain. _charset is th...
python.library.email.mime#email.mime.text.MIMEText
class email.parser.BytesFeedParser(_factory=None, *, policy=policy.compat32) Create a BytesFeedParser instance. Optional _factory is a no-argument callable; if not specified use the message_factory from the policy. Call _factory whenever a new message object is needed. If policy is specified use the rules it specifie...
python.library.email.parser#email.parser.BytesFeedParser
close() Complete the parsing of all previously fed data and return the root message object. It is undefined what happens if feed() is called after this method has been called.
python.library.email.parser#email.parser.BytesFeedParser.close
feed(data) Feed the parser some more data. data should be a bytes-like object containing one or more lines. The lines can be partial and the parser will stitch such partial lines together properly. The lines can have any of the three common line endings: carriage return, newline, or carriage return and newline (they ...
python.library.email.parser#email.parser.BytesFeedParser.feed
class email.parser.BytesHeaderParser(_class=None, *, policy=policy.compat32) Exactly like BytesParser, except that headersonly defaults to True. New in version 3.3.
python.library.email.parser#email.parser.BytesHeaderParser
class email.parser.BytesParser(_class=None, *, policy=policy.compat32) Create a BytesParser instance. The _class and policy arguments have the same meaning and semantics as the _factory and policy arguments of BytesFeedParser. Note: The policy keyword should always be specified; The default will change to email.polic...
python.library.email.parser#email.parser.BytesParser
parse(fp, headersonly=False) Read all the data from the binary file-like object fp, parse the resulting bytes, and return the message object. fp must support both the readline() and the read() methods. The bytes contained in fp must be formatted as a block of RFC 5322 (or, if utf8 is True, RFC 6532) style headers and...
python.library.email.parser#email.parser.BytesParser.parse
parsebytes(bytes, headersonly=False) Similar to the parse() method, except it takes a bytes-like object instead of a file-like object. Calling this method on a bytes-like object is equivalent to wrapping bytes in a BytesIO instance first and calling parse(). Optional headersonly is as with the parse() method.
python.library.email.parser#email.parser.BytesParser.parsebytes
class email.parser.FeedParser(_factory=None, *, policy=policy.compat32) Works like BytesFeedParser except that the input to the feed() method must be a string. This is of limited utility, since the only way for such a message to be valid is for it to contain only ASCII text or, if utf8 is True, no binary attachments....
python.library.email.parser#email.parser.FeedParser
class email.parser.HeaderParser(_class=None, *, policy=policy.compat32) Exactly like Parser, except that headersonly defaults to True.
python.library.email.parser#email.parser.HeaderParser
class email.parser.Parser(_class=None, *, policy=policy.compat32) This class is parallel to BytesParser, but handles string input. Changed in version 3.3: Removed the strict argument. Added the policy keyword. Changed in version 3.6: _class defaults to the policy message_factory. parse(fp, headersonly=False) ...
python.library.email.parser#email.parser.Parser
parse(fp, headersonly=False) Read all the data from the text-mode file-like object fp, parse the resulting text, and return the root message object. fp must support both the readline() and the read() methods on file-like objects. Other than the text mode requirement, this method operates like BytesParser.parse().
python.library.email.parser#email.parser.Parser.parse
parsestr(text, headersonly=False) Similar to the parse() method, except it takes a string object instead of a file-like object. Calling this method on a string is equivalent to wrapping text in a StringIO instance first and calling parse(). Optional headersonly is as with the parse() method.
python.library.email.parser#email.parser.Parser.parsestr
email.policy.compat32 An instance of Compat32, providing backward compatibility with the behavior of the email package in Python 3.2.
python.library.email.policy#email.policy.compat32
class email.policy.Compat32(**kw) This concrete Policy is the backward compatibility policy. It replicates the behavior of the email package in Python 3.2. The policy module also defines an instance of this class, compat32, that is used as the default policy. Thus the default behavior of the email package is to maint...
python.library.email.policy#email.policy.Compat32
fold(name, value) Headers are folded using the Header folding algorithm, which preserves existing line breaks in the value, and wraps each resulting line to the max_line_length. Non-ASCII binary data are CTE encoded using the unknown-8bit charset.
python.library.email.policy#email.policy.Compat32.fold
fold_binary(name, value) Headers are folded using the Header folding algorithm, which preserves existing line breaks in the value, and wraps each resulting line to the max_line_length. If cte_type is 7bit, non-ascii binary data is CTE encoded using the unknown-8bit charset. Otherwise the original source header is use...
python.library.email.policy#email.policy.Compat32.fold_binary
header_fetch_parse(name, value) If the value contains binary data, it is converted into a Header object using the unknown-8bit charset. Otherwise it is returned unmodified.
python.library.email.policy#email.policy.Compat32.header_fetch_parse
header_source_parse(sourcelines) The name is parsed as everything up to the ‘:’ and returned unmodified. The value is determined by stripping leading whitespace off the remainder of the first line, joining all subsequent lines together, and stripping any trailing carriage return or linefeed characters.
python.library.email.policy#email.policy.Compat32.header_source_parse
header_store_parse(name, value) The name and value are returned unmodified.
python.library.email.policy#email.policy.Compat32.header_store_parse
mangle_from_ The default is True.
python.library.email.policy#email.policy.Compat32.mangle_from_
email.policy.default An instance of EmailPolicy with all defaults unchanged. This policy uses the standard Python \n line endings rather than the RFC-correct \r\n.
python.library.email.policy#email.policy.default
class email.policy.EmailPolicy(**kw) This concrete Policy provides behavior that is intended to be fully compliant with the current email RFCs. These include (but are not limited to) RFC 5322, RFC 2047, and the current MIME RFCs. This policy adds new header parsing and folding algorithms. Instead of simple strings, h...
python.library.email.policy#email.policy.EmailPolicy
content_manager An object with at least two methods: get_content and set_content. When the get_content() or set_content() method of an EmailMessage object is called, it calls the corresponding method of this object, passing it the message object as its first argument, and any arguments or keywords that were passed to...
python.library.email.policy#email.policy.EmailPolicy.content_manager
fold(name, value) Header folding is controlled by the refold_source policy setting. A value is considered to be a ‘source value’ if and only if it does not have a name attribute (having a name attribute means it is a header object of some sort). If a source value needs to be refolded according to the policy, it is co...
python.library.email.policy#email.policy.EmailPolicy.fold
fold_binary(name, value) The same as fold() if cte_type is 7bit, except that the returned value is bytes. If cte_type is 8bit, non-ASCII binary data is converted back into bytes. Headers with binary data are not refolded, regardless of the refold_header setting, since there is no way to know whether the binary data c...
python.library.email.policy#email.policy.EmailPolicy.fold_binary
header_factory A callable that takes two arguments, name and value, where name is a header field name and value is an unfolded header field value, and returns a string subclass that represents that header. A default header_factory (see headerregistry) is provided that supports custom parsing for the various address a...
python.library.email.policy#email.policy.EmailPolicy.header_factory
header_fetch_parse(name, value) If the value has a name attribute, it is returned to unmodified. Otherwise the name, and the value with any CR or LF characters removed, are passed to the header_factory, and the resulting header object is returned. Any surrogateescaped bytes get turned into the unicode unknown-charact...
python.library.email.policy#email.policy.EmailPolicy.header_fetch_parse
header_max_count(name) Returns the value of the max_count attribute of the specialized class used to represent the header with the given name.
python.library.email.policy#email.policy.EmailPolicy.header_max_count
header_source_parse(sourcelines) The name is parsed as everything up to the ‘:’ and returned unmodified. The value is determined by stripping leading whitespace off the remainder of the first line, joining all subsequent lines together, and stripping any trailing carriage return or linefeed characters.
python.library.email.policy#email.policy.EmailPolicy.header_source_parse
header_store_parse(name, value) The name is returned unchanged. If the input value has a name attribute and it matches name ignoring case, the value is returned unchanged. Otherwise the name and value are passed to header_factory, and the resulting header object is returned as the value. In this case a ValueError is ...
python.library.email.policy#email.policy.EmailPolicy.header_store_parse
refold_source If the value for a header in the Message object originated from a parser (as opposed to being set by a program), this attribute indicates whether or not a generator should refold that value when transforming the message back into serialized form. The possible values are: none all source values use ori...
python.library.email.policy#email.policy.EmailPolicy.refold_source
utf8 If False, follow RFC 5322, supporting non-ASCII characters in headers by encoding them as “encoded words”. If True, follow RFC 6532 and use utf-8 encoding for headers. Messages formatted in this way may be passed to SMTP servers that support the SMTPUTF8 extension (RFC 6531).
python.library.email.policy#email.policy.EmailPolicy.utf8
email.policy.HTTP Suitable for serializing headers with for use in HTTP traffic. Like SMTP except that max_line_length is set to None (unlimited).
python.library.email.policy#email.policy.HTTP
class email.policy.Policy(**kw) This is the abstract base class for all policy classes. It provides default implementations for a couple of trivial methods, as well as the implementation of the immutability property, the clone() method, and the constructor semantics. The constructor of a policy class can be passed va...
python.library.email.policy#email.policy.Policy
clone(**kw) Return a new Policy instance whose attributes have the same values as the current instance, except where those attributes are given new values by the keyword arguments.
python.library.email.policy#email.policy.Policy.clone
cte_type Controls the type of Content Transfer Encodings that may be or are required to be used. The possible values are: 7bit all data must be “7 bit clean” (ASCII-only). This means that where necessary data will be encoded using either quoted-printable or base64 encoding. 8bit data is not constrained to be 7 bi...
python.library.email.policy#email.policy.Policy.cte_type
fold(name, value) The email package calls this method with the name and value currently stored in the Message for a given header. The method should return a string that represents that header “folded” correctly (according to the policy settings) by composing the name with the value and inserting linesep characters at...
python.library.email.policy#email.policy.Policy.fold
fold_binary(name, value) The same as fold(), except that the returned value should be a bytes object rather than a string. value may contain surrogateescaped binary data. These could be converted back into binary data in the returned bytes object.
python.library.email.policy#email.policy.Policy.fold_binary
handle_defect(obj, defect) Handle a defect found on obj. When the email package calls this method, defect will always be a subclass of Defect. The default implementation checks the raise_on_defect flag. If it is True, defect is raised as an exception. If it is False (the default), obj and defect are passed to registe...
python.library.email.policy#email.policy.Policy.handle_defect
header_fetch_parse(name, value) The email package calls this method with the name and value currently stored in the Message when that header is requested by the application program, and whatever the method returns is what is passed back to the application as the value of the header being retrieved. Note that there ma...
python.library.email.policy#email.policy.Policy.header_fetch_parse
header_max_count(name) Return the maximum allowed number of headers named name. Called when a header is added to an EmailMessage or Message object. If the returned value is not 0 or None, and there are already a number of headers with the name name greater than or equal to the value returned, a ValueError is raised. ...
python.library.email.policy#email.policy.Policy.header_max_count
header_source_parse(sourcelines) The email package calls this method with a list of strings, each string ending with the line separation characters found in the source being parsed. The first line includes the field header name and separator. All whitespace in the source is preserved. The method should return the (na...
python.library.email.policy#email.policy.Policy.header_source_parse
header_store_parse(name, value) The email package calls this method with the name and value provided by the application program when the application program is modifying a Message programmatically (as opposed to a Message created by a parser). The method should return the (name, value) tuple that is to be stored in t...
python.library.email.policy#email.policy.Policy.header_store_parse
linesep The string to be used to terminate lines in serialized output. The default is \n because that’s the internal end-of-line discipline used by Python, though \r\n is required by the RFCs.
python.library.email.policy#email.policy.Policy.linesep
mangle_from_ If True, lines starting with “From “ in the body are escaped by putting a > in front of them. This parameter is used when the message is being serialized by a generator. Default: False. New in version 3.5: The mangle_from_ parameter.
python.library.email.policy#email.policy.Policy.mangle_from_
max_line_length The maximum length of any line in the serialized output, not counting the end of line character(s). Default is 78, per RFC 5322. A value of 0 or None indicates that no line wrapping should be done at all.
python.library.email.policy#email.policy.Policy.max_line_length
message_factory A factory function for constructing a new empty message object. Used by the parser when building messages. Defaults to None, in which case Message is used. New in version 3.6.
python.library.email.policy#email.policy.Policy.message_factory
raise_on_defect If True, any defects encountered will be raised as errors. If False (the default), defects will be passed to the register_defect() method.
python.library.email.policy#email.policy.Policy.raise_on_defect
register_defect(obj, defect) Register a defect on obj. In the email package, defect will always be a subclass of Defect. The default implementation calls the append method of the defects attribute of obj. When the email package calls handle_defect, obj will normally have a defects attribute that has an append method....
python.library.email.policy#email.policy.Policy.register_defect
email.policy.SMTP Suitable for serializing messages in conformance with the email RFCs. Like default, but with linesep set to \r\n, which is RFC compliant.
python.library.email.policy#email.policy.SMTP
email.policy.SMTPUTF8 The same as SMTP except that utf8 is True. Useful for serializing messages to a message store without using encoded words in the headers. Should only be used for SMTP transmission if the sender or recipient addresses have non-ASCII characters (the smtplib.SMTP.send_message() method handles this ...
python.library.email.policy#email.policy.SMTPUTF8
email.policy.strict Convenience instance. The same as default except that raise_on_defect is set to True. This allows any policy to be made strict by writing: somepolicy + policy.strict
python.library.email.policy#email.policy.strict
email.utils.collapse_rfc2231_value(value, errors='replace', fallback_charset='us-ascii') When a header parameter is encoded in RFC 2231 format, Message.get_param may return a 3-tuple containing the character set, language, and value. collapse_rfc2231_value() turns this into a unicode string. Optional errors is passed...
python.library.email.utils#email.utils.collapse_rfc2231_value
email.utils.decode_params(params) Decode parameters list according to RFC 2231. params is a sequence of 2-tuples containing elements of the form (content-type, string-value).
python.library.email.utils#email.utils.decode_params
email.utils.decode_rfc2231(s) Decode the string s according to RFC 2231.
python.library.email.utils#email.utils.decode_rfc2231
email.utils.encode_rfc2231(s, charset=None, language=None) Encode the string s according to RFC 2231. Optional charset and language, if given is the character set name and language name to use. If neither is given, s is returned as-is. If charset is given but language is not, the string is encoded using the empty str...
python.library.email.utils#email.utils.encode_rfc2231
email.utils.formataddr(pair, charset='utf-8') The inverse of parseaddr(), this takes a 2-tuple of the form (realname, email_address) and returns the string value suitable for a To or Cc header. If the first element of pair is false, then the second element is returned unmodified. Optional charset is the character set...
python.library.email.utils#email.utils.formataddr
email.utils.formatdate(timeval=None, localtime=False, usegmt=False) Returns a date string as per RFC 2822, e.g.: Fri, 09 Nov 2001 01:08:47 -0000 Optional timeval if given is a floating point time value as accepted by time.gmtime() and time.localtime(), otherwise the current time is used. Optional localtime is a flag...
python.library.email.utils#email.utils.formatdate
email.utils.format_datetime(dt, usegmt=False) Like formatdate, but the input is a datetime instance. If it is a naive datetime, it is assumed to be “UTC with no information about the source timezone”, and the conventional -0000 is used for the timezone. If it is an aware datetime, then the numeric timezone offset is ...
python.library.email.utils#email.utils.format_datetime
email.utils.getaddresses(fieldvalues) This method returns a list of 2-tuples of the form returned by parseaddr(). fieldvalues is a sequence of header field values as might be returned by Message.get_all. Here’s a simple example that gets all the recipients of a message: from email.utils import getaddresses tos = msg...
python.library.email.utils#email.utils.getaddresses
email.utils.localtime(dt=None) Return local time as an aware datetime object. If called without arguments, return current time. Otherwise dt argument should be a datetime instance, and it is converted to the local time zone according to the system time zone database. If dt is naive (that is, dt.tzinfo is None), it is...
python.library.email.utils#email.utils.localtime
email.utils.make_msgid(idstring=None, domain=None) Returns a string suitable for an RFC 2822-compliant Message-ID header. Optional idstring if given, is a string used to strengthen the uniqueness of the message id. Optional domain if given provides the portion of the msgid after the ‘@’. The default is the local host...
python.library.email.utils#email.utils.make_msgid
email.utils.mktime_tz(tuple) Turn a 10-tuple as returned by parsedate_tz() into a UTC timestamp (seconds since the Epoch). If the timezone item in the tuple is None, assume local time.
python.library.email.utils#email.utils.mktime_tz
email.utils.parseaddr(address) Parse address – which should be the value of some address-containing field such as To or Cc – into its constituent realname and email address parts. Returns a tuple of that information, unless the parse fails, in which case a 2-tuple of ('', '') is returned.
python.library.email.utils#email.utils.parseaddr
email.utils.parsedate(date) Attempts to parse a date according to the rules in RFC 2822. however, some mailers don’t follow that format as specified, so parsedate() tries to guess correctly in such cases. date is a string containing an RFC 2822 date, such as "Mon, 20 Nov 1995 19:12:08 -0500". If it succeeds in parsin...
python.library.email.utils#email.utils.parsedate
email.utils.parsedate_to_datetime(date) The inverse of format_datetime(). Performs the same function as parsedate(), but on success returns a datetime. If the input date has a timezone of -0000, the datetime will be a naive datetime, and if the date is conforming to the RFCs it will represent a time in UTC but with n...
python.library.email.utils#email.utils.parsedate_to_datetime
email.utils.parsedate_tz(date) Performs the same function as parsedate(), but returns either None or a 10-tuple; the first 9 elements make up a tuple that can be passed directly to time.mktime(), and the tenth is the offset of the date’s timezone from UTC (which is the official term for Greenwich Mean Time) 1. If the...
python.library.email.utils#email.utils.parsedate_tz
email.utils.quote(str) Return a new string with backslashes in str replaced by two backslashes, and double quotes replaced by backslash-double quote.
python.library.email.utils#email.utils.quote
email.utils.unquote(str) Return a new string which is an unquoted version of str. If str ends and begins with double quotes, they are stripped off. Likewise if str ends and begins with angle brackets, they are stripped off.
python.library.email.utils#email.utils.unquote
encodings.idna.nameprep(label) Return the nameprepped version of label. The implementation currently assumes query strings, so AllowUnassigned is true.
python.library.codecs#encodings.idna.nameprep
encodings.idna.ToASCII(label) Convert a label to ASCII, as specified in RFC 3490. UseSTD3ASCIIRules is assumed to be false.
python.library.codecs#encodings.idna.ToASCII
encodings.idna.ToUnicode(label) Convert a label to Unicode, as specified in RFC 3490.
python.library.codecs#encodings.idna.ToUnicode
ensurepip — Bootstrapping the pip installer New in version 3.4. The ensurepip package provides support for bootstrapping the pip installer into an existing Python installation or virtual environment. This bootstrapping approach reflects the fact that pip is an independent project with its own release cycle, and the l...
python.library.ensurepip
ensurepip.bootstrap(root=None, upgrade=False, user=False, altinstall=False, default_pip=False, verbosity=0) Bootstraps pip into the current or designated environment. root specifies an alternative root directory to install relative to. If root is None, then installation uses the default install location for the curre...
python.library.ensurepip#ensurepip.bootstrap
ensurepip.version() Returns a string specifying the bundled version of pip that will be installed when bootstrapping an environment.
python.library.ensurepip#ensurepip.version
enum — Support for enumerations New in version 3.4. Source code: Lib/enum.py An enumeration is a set of symbolic names (members) bound to unique, constant values. Within an enumeration, the members can be compared by identity, and the enumeration itself can be iterated over. Note Case of Enum Members Because Enums a...
python.library.enum
class enum.auto Instances are replaced with an appropriate value for Enum members. By default, the initial value starts at 1.
python.library.enum#enum.auto
class enum.Enum Base class for creating enumerated constants. See section Functional API for an alternate construction syntax.
python.library.enum#enum.Enum
class enum.Flag Base class for creating enumerated constants that can be combined using the bitwise operations without losing their Flag membership.
python.library.enum#enum.Flag
class enum.IntEnum Base class for creating enumerated constants that are also subclasses of int.
python.library.enum#enum.IntEnum
class enum.IntFlag Base class for creating enumerated constants that can be combined using the bitwise operators without losing their IntFlag membership. IntFlag members are also subclasses of int.
python.library.enum#enum.IntFlag
@enum.unique
python.library.enum#enum.unique
enumerate(iterable, start=0) Return an enumerate object. iterable must be a sequence, an iterator, or some other object which supports iteration. The __next__() method of the iterator returned by enumerate() returns a tuple containing a count (from start which defaults to 0) and the values obtained from iterating ove...
python.library.functions#enumerate
exception EnvironmentError
python.library.exceptions#EnvironmentError
exception EOFError Raised when the input() function hits an end-of-file condition (EOF) without reading any data. (N.B.: the io.IOBase.read() and io.IOBase.readline() methods return an empty string when they hit EOF.)
python.library.exceptions#EOFError
errno — Standard errno system symbols This module makes available standard errno system symbols. The value of each symbol is the corresponding integer value. The names and descriptions are borrowed from linux/include/errno.h, which should be pretty all-inclusive. errno.errorcode Dictionary providing a mapping from ...
python.library.errno
eval(expression[, globals[, locals]]) The arguments are a string and optional globals and locals. If provided, globals must be a dictionary. If provided, locals can be any mapping object. The expression argument is parsed and evaluated as a Python expression (technically speaking, a condition list) using the globals ...
python.library.functions#eval
exception Exception All built-in, non-system-exiting exceptions are derived from this class. All user-defined exceptions should also be derived from this class.
python.library.exceptions#Exception
Exceptions Source code: Lib/asyncio/exceptions.py exception asyncio.TimeoutError The operation has exceeded the given deadline. Important This exception is different from the builtin TimeoutError exception. exception asyncio.CancelledError The operation has been cancelled. This exception can be caught to pe...
python.library.asyncio-exceptions
Built-in Exceptions In Python, all exceptions must be instances of a class that derives from BaseException. In a try statement with an except clause that mentions a particular class, that clause also handles any exception classes derived from that class (but not exception classes from which it is derived). Two exceptio...
python.library.exceptions
exec(object[, globals[, locals]]) This function supports dynamic execution of Python code. object must be either a string or a code object. If it is a string, the string is parsed as a suite of Python statements which is then executed (unless a syntax error occurs). 1 If it is a code object, it is simply executed. In...
python.library.functions#exec
quit(code=None) exit(code=None) Objects that when printed, print a message like “Use quit() or Ctrl-D (i.e. EOF) to exit”, and when called, raise SystemExit with the specified exit code.
python.library.constants#exit
False The false value of the bool type. Assignments to False are illegal and raise a SyntaxError.
python.library.constants#False
faulthandler — Dump the Python traceback New in version 3.3. This module contains functions to dump Python tracebacks explicitly, on a fault, after a timeout, or on a user signal. Call faulthandler.enable() to install fault handlers for the SIGSEGV, SIGFPE, SIGABRT, SIGBUS, and SIGILL signals. You can also enable the...
python.library.faulthandler
faulthandler.cancel_dump_traceback_later() Cancel the last call to dump_traceback_later().
python.library.faulthandler#faulthandler.cancel_dump_traceback_later
faulthandler.disable() Disable the fault handler: uninstall the signal handlers installed by enable().
python.library.faulthandler#faulthandler.disable
faulthandler.dump_traceback(file=sys.stderr, all_threads=True) Dump the tracebacks of all threads into file. If all_threads is False, dump only the current thread. Changed in version 3.5: Added support for passing file descriptor to this function.
python.library.faulthandler#faulthandler.dump_traceback
faulthandler.dump_traceback_later(timeout, repeat=False, file=sys.stderr, exit=False) Dump the tracebacks of all threads, after a timeout of timeout seconds, or every timeout seconds if repeat is True. If exit is True, call _exit() with status=1 after dumping the tracebacks. (Note _exit() exits the process immediatel...
python.library.faulthandler#faulthandler.dump_traceback_later