links encountered in the path (if they are supported by the operating system).
-.. function:: relpath(path[, start])
+.. function:: relpath(path, start=None)
Return a relative filepath to *path* either from the current directory or from
an optional *start* point.
Return the current process's user id. Availability: Unix.
-.. function:: getenv(varname[, value])
+.. function:: getenv(key, default=None)
- Return the value of the environment variable *varname* if it exists, or *value*
- if it doesn't. *value* defaults to ``None``. Availability: most flavors of
- Unix, Windows.
+ Return the value of the environment variable *key* if it exists, or
+ *default* if it doesn't. Availability: most flavors of Unix, Windows.
-.. function:: putenv(varname, value)
+.. function:: putenv(key, value)
.. index:: single: environment variables; setting
- Set the environment variable named *varname* to the string *value*. Such
+ Set the environment variable named *key* to the string *value*. Such
changes to the environment affect subprocesses started with :func:`os.system`,
:func:`popen` or :func:`fork` and :func:`execv`. Availability: most flavors of
Unix, Windows.
Unix.
-.. function:: unsetenv(varname)
+.. function:: unsetenv(key)
.. index:: single: environment variables; deleting
- Unset (delete) the environment variable named *varname*. Such changes to the
+ Unset (delete) the environment variable named *key*. Such changes to the
environment affect subprocesses started with :func:`os.system`, :func:`popen` or
:func:`fork` and :func:`execv`. Availability: most flavors of Unix, Windows.
doesn't open the FIFO --- it just creates the rendezvous point.
-.. function:: mknod(filename[, mode=0o600, device])
+.. function:: mknod(filename[, mode=0o600[, device]])
Create a filesystem node (file, device special file or named pipe) named
- *filename*. *mode* specifies both the permissions to use and the type of node to
- be created, being combined (bitwise OR) with one of ``stat.S_IFREG``,
- ``stat.S_IFCHR``, ``stat.S_IFBLK``,
- and ``stat.S_IFIFO`` (those constants are available in :mod:`stat`).
- For ``stat.S_IFCHR`` and
- ``stat.S_IFBLK``, *device* defines the newly created device special file (probably using
+ *filename*. *mode* specifies both the permissions to use and the type of node
+ to be created, being combined (bitwise OR) with one of ``stat.S_IFREG``,
+ ``stat.S_IFCHR``, ``stat.S_IFBLK``, and ``stat.S_IFIFO`` (those constants are
+ available in :mod:`stat`). For ``stat.S_IFCHR`` and ``stat.S_IFBLK``,
+ *device* defines the newly created device special file (probably using
:func:`os.makedev`), otherwise it is ignored.
Availability: Unix, Windows.
-.. function:: walk(top[, topdown=True [, onerror=None[, followlinks=False]]])
+.. function:: walk(top, topdown=True, onerror=None, followlinks=False)
.. index::
single: directory; walking
-
:mod:`ossaudiodev` --- Access to OSS-compatible audio devices
=============================================================
-
:mod:`parser` --- Access Python parse trees
===========================================
numbering information.
-.. function:: st2list(st[, line_info])
+.. function:: st2list(st, line_info=False, col_info=False)
This function accepts an ST object from the caller in *st* and returns a
Python list representing the equivalent parse tree. The resulting list
This information is omitted if the flag is false or omitted.
-.. function:: st2tuple(st[, line_info])
+.. function:: st2tuple(st, line_info=False, col_info=False)
This function accepts an ST object from the caller in *st* and returns a
Python tuple representing the equivalent parse tree. Other than returning a
information is omitted if the flag is false or omitted.
-.. function:: compilest(st[, filename='<syntax-tree>'])
+.. function:: compilest(st, filename='<syntax-tree>')
.. index::
builtin: exec
ST objects have the following methods:
-.. method:: ST.compile([filename])
+.. method:: ST.compile(filename='<syntax-tree>')
Same as ``compilest(st, filename)``.
Same as ``issuite(st)``.
-.. method:: ST.tolist([line_info])
+.. method:: ST.tolist(line_info=False, col_info=False)
- Same as ``st2list(st, line_info)``.
+ Same as ``st2list(st, line_info, col_info)``.
-.. method:: ST.totuple([line_info])
+.. method:: ST.totuple(line_info=False, col_info=False)
- Same as ``st2tuple(st, line_info)``.
+ Same as ``st2tuple(st, line_info, col_info)``.
.. _st-examples:
The module defines the following functions; each enters the debugger in a
slightly different way:
-.. function:: run(statement[, globals[, locals]])
+.. function:: run(statement, globals=None, locals=None)
Execute the *statement* (given as a string) under debugger control. The
debugger prompt appears before any code is executed; you can set breakpoints and
explanation of the built-in :func:`exec` or :func:`eval` functions.)
-.. function:: runeval(expression[, globals[, locals]])
+.. function:: runeval(expression, globals=None, locals=None)
Evaluate the *expression* (given as a string) under debugger control. When
:func:`runeval` returns, it returns the value of the expression. Otherwise this
function is similar to :func:`run`.
-.. function:: runcall(function[, argument, ...])
+.. function:: runcall(function, *args, **kwds)
Call the *function* (a function or method object, not a string) with the given
arguments. When :func:`runcall` returns, it returns whatever the function call
being debugged (e.g. when an assertion fails).
-.. function:: post_mortem([traceback])
+.. function:: post_mortem(traceback=None)
Enter post-mortem debugging of the given *traceback* object. If no
*traceback* is given, it uses the one of the exception that is currently
.. versionadded:: 3.1
The *skip* argument.
- .. method:: run(statement[, globals[, locals]])
- runeval(expression[, globals[, locals]])
- runcall(function[, argument, ...])
+ .. method:: run(statement, globals=None, locals=None)
+ runeval(expression, globals=None, locals=None)
+ runcall(function, *args, **kwds)
set_trace()
See the documentation for the functions explained above.
-
.. _persistence:
****************
The :mod:`pickle` module provides the following functions to make the pickling
process more convenient:
-.. function:: dump(obj, file[, protocol, \*, fix_imports=True])
+.. function:: dump(obj, file, protocol=None, \*, fix_imports=True)
Write a pickled representation of *obj* to the open file object *file*. This
is equivalent to ``Pickler(file, protocol).dump(obj)``.
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
-.. function:: dumps(obj[, protocol, \*, fix_imports=True])
+.. function:: dumps(obj, protocol=None, \*, fix_imports=True)
Return the pickled representation of the object as a :class:`bytes`
object, instead of writing it to a file.
map the new Python 3.x names to the old module names used in Python 2.x,
so that the pickle data stream is readable with Python 2.x.
-.. function:: load(file, [\*, fix_imports=True, encoding="ASCII", errors="strict"])
+.. function:: load(file, \*, fix_imports=True, encoding="ASCII", errors="strict")
Read a pickled object representation from the open file object *file* and
return the reconstituted object hierarchy specified therein. This is
*errors* tell pickle how to decode 8-bit string instances pickled by Python
2.x; these default to 'ASCII' and 'strict', respectively.
-.. function:: loads(bytes_object, [\*, fix_imports=True, encoding="ASCII", errors="strict"])
+.. function:: loads(bytes_object, \*, fix_imports=True, encoding="ASCII", errors="strict")
Read a pickled object hierarchy from a :class:`bytes` object and return the
reconstituted object hierarchy specified therein
The :mod:`pickle` module exports two classes, :class:`Pickler` and
:class:`Unpickler`:
-.. class:: Pickler(file[, protocol, \*, fix_imports=True])
+.. class:: Pickler(file, protocol=None, \*, fix_imports=True)
This takes a binary file for writing a pickle data stream.
Use :func:`pickletools.optimize` if you need more compact pickles.
-.. class:: Unpickler(file, [\*, fix_imports=True, encoding="ASCII", errors="strict"])
+.. class:: Unpickler(file, \*, fix_imports=True, encoding="ASCII", errors="strict")
This takes a binary file for reading a pickle data stream.
==================================================
.. module:: pickletools
- :synopsis: Contains extensive comments about the pickle protocols and pickle-machine opcodes, as well as some useful functions.
+ :synopsis: Contains extensive comments about the pickle protocols and
+ pickle-machine opcodes, as well as some useful functions.
This module contains various constants relating to the intimate details of the
:mod:`pickle` module, some lengthy comments about the implementation, and a
:mod:`pickletools` module relevant.
-.. function:: dis(pickle[, out=None, memo=None, indentlevel=4])
+.. function:: dis(pickle, out=None, memo=None, indentlevel=4)
Outputs a symbolic disassembly of the pickle to the file-like object *out*,
defaulting to ``sys.stdout``. *pickle* can be a string or a file-like object.
-
:mod:`pipes` --- Interface to shell pipelines
=============================================
-
:mod:`pkgutil` --- Package extension utility
============================================
-
:mod:`poplib` --- POP3 protocol client
======================================
A single class is provided by the :mod:`poplib` module:
-.. class:: POP3(host[, port[, timeout]])
+.. class:: POP3(host, port=POP3_PORT[, timeout])
This class implements the actual POP3 protocol. The connection is created when
the instance is initialized. If *port* is omitted, the standard POP3 port (110)
be used).
-.. class:: POP3_SSL(host[, port[, keyfile[, certfile]]])
+.. class:: POP3_SSL(host, port=POP3_SSL_PORT, keyfile=None, certfile=None[, timeout])
This is a subclass of :class:`POP3` that connects to the server over an SSL
encrypted socket. If *port* is not specified, 995, the standard POP3-over-SSL
port is used. *keyfile* and *certfile* are also optional - they can contain a
PEM formatted private key and certificate chain file for the SSL connection.
+ *timeout* works as in the :class:`POP3` constructor.
One exception is defined as an attribute of the :mod:`poplib` module:
POP3 servers you will use before trusting it.
-.. method:: POP3.uidl([which])
+.. method:: POP3.uidl(which=None)
Return message digest (unique id) list. If *which* is specified, result contains
the unique id for that message in the form ``'response mesgnum uid``, otherwise
-
:mod:`pprint` --- Data pretty printer
=====================================
.. First the implementation class:
-.. class:: PrettyPrinter(...)
+.. class:: PrettyPrinter(indent=1, width=80, depth=None, stream=None)
Construct a :class:`PrettyPrinter` instance. This constructor understands
several keyword parameters. An output stream may be set using the *stream*
>>> pp.pprint(tup)
('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead', (...)))))))
-The :class:`PrettyPrinter` class supports several derivative functions:
-.. Now the derivative functions:
+The :class:`PrettyPrinter` class supports several derivative functions:
-.. function:: pformat(object[, indent[, width[, depth]]])
+.. function:: pformat(object, indent=1, width=80, depth=None)
Return the formatted representation of *object* as a string. *indent*, *width*
and *depth* will be passed to the :class:`PrettyPrinter` constructor as
formatting parameters.
-.. function:: pprint(object[, stream[, indent[, width[, depth]]]])
+.. function:: pprint(object, stream=None, indent=1, width=80, depth=None)
Prints the formatted representation of *object* on *stream*, followed by a
- newline. If *stream* is omitted, ``sys.stdout`` is used. This may be used
+ newline. If *stream* is ``None``, ``sys.stdout`` is used. This may be used
in the interactive interpreter instead of the :func:`print` function for
inspecting values (you can even reassign ``print = pprint.pprint`` for use
within a scope). *indent*, *width* and *depth* will be passed to the
pprint Example
--------------
-This example demonstrates several uses of the :func:`pprint` function and its parameters.
+This example demonstrates several uses of the :func:`pprint` function and its
+parameters.
>>> import pprint
>>> tup = ('spam', ('eggs', ('lumberjack', ('knights', ('ni', ('dead',
-
.. _profile:
********************
reading the source code for these modules.
-.. function:: run(command[, filename])
+.. function:: run(command, filename=None, sort=-1)
This function takes a single argument that can be passed to the :func:`exec`
function, and an optional file name. In all cases this routine attempts to
for the number of calls,
tottime
- for the total time spent in the given function (and excluding time made in calls
- to sub-functions),
+ for the total time spent in the given function (and excluding time made in
+ calls to sub-functions),
percall
is the quotient of ``tottime`` divided by ``ncalls``
calls. Note that when the function does not recurse, these two values are the
same, and only the single figure is printed.
+ If *sort* is given, it can be one of ``'stdname'`` (sort by filename:lineno),
+ ``'calls'`` (sort by number of calls), ``'time'`` (sort by total time) or
+ ``'cumulative'`` (sort by cumulative time). The default is ``'stdname'``.
+
-.. function:: runctx(command, globals, locals[, filename])
+.. function:: runctx(command, globals, locals, filename=None)
This function is similar to :func:`run`, with added arguments to supply the
globals and locals dictionaries for the *command* string.
-Analysis of the profiler data is done using the :class:`Stats` class.
-
-.. note::
- The :class:`Stats` class is defined in the :mod:`pstats` module.
+Analysis of the profiler data is done using the :class:`pstats.Stats` class.
.. module:: pstats
:synopsis: Statistics object for use with the profiler.
-.. class:: Stats(filename[, stream=sys.stdout[, ...]])
+.. class:: Stats(*filenames, stream=sys.stdout)
This class constructor creates an instance of a "statistics object" from a
*filename* (or set of filenames). :class:`Stats` objects are manipulated by
accumulated into a single entry.
-.. method:: Stats.add(filename[, ...])
+.. method:: Stats.add(*filenames)
This method of the :class:`Stats` class accumulates additional profiling
information into the current profiling object. Its arguments should refer to
:class:`profile.Profile` and :class:`cProfile.Profile` classes.
-.. method:: Stats.sort_stats(key[, ...])
+.. method:: Stats.sort_stats(*keys)
This method modifies the :class:`Stats` object by sorting it according to the
supplied criteria. The argument is typically a string identifying the basis of
.. This method is provided primarily for compatibility with the old profiler.
-.. method:: Stats.print_stats([restriction, ...])
+.. method:: Stats.print_stats(*restrictions)
This method for the :class:`Stats` class prints out a report as described in the
:func:`profile.run` definition.
then proceed to only print the first 10% of them.
-.. method:: Stats.print_callers([restriction, ...])
+.. method:: Stats.print_callers(*restrictions)
This method for the :class:`Stats` class prints a list of all functions that
called each function in the profiled database. The ordering is identical to
the current function while it was invoked by this specific caller.
-.. method:: Stats.print_callees([restriction, ...])
+.. method:: Stats.print_callees(*restrictions)
This method for the :class:`Stats` class prints a list of all function that were
called by the indicated function. Aside from this reversal of direction of
-
:mod:`pty` --- Pseudo-terminal utilities
========================================
-
:mod:`pwd` --- The password database
====================================
Exception raised when an error occurs while attempting to compile the file.
-.. function:: compile(file[, cfile[, dfile[, doraise]]])
+.. function:: compile(file, cfile=None, dfile=None, doraise=False)
Compile a source file to byte-code and write out the byte-code cache file. The
source code is loaded from the file name *file*. The byte-code is written to
written to ``sys.stderr``, but no exception is raised.
-.. function:: main([args])
+.. function:: main(args=None)
Compile several source files. The files named in *args* (or on the command
- line, if *args* is not specified) are compiled and the resulting bytecode is
+ line, if *args* is ``None``) are compiled and the resulting bytecode is
cached in the normal manner. This function does not search a directory
structure to locate source files; it only compiles files named explicitly.
-
:mod:`pyclbr` --- Python class browser support
==============================================
modules.
-.. function:: readmodule(module[, path=None])
+.. function:: readmodule(module, path=None)
Read a module and return a dictionary mapping class names to class
descriptor objects. The parameter *module* should be the name of a
of ``sys.path``, which is used to locate module source code.
-.. function:: readmodule_ex(module[, path=None])
+.. function:: readmodule_ex(module, path=None)
Like :func:`readmodule`, but the returned dictionary, in addition to
mapping class names to class descriptor objects, also maps top-level
-
:mod:`pydoc` --- Documentation generator and online help system
===============================================================
-
:mod:`xml.parsers.expat` --- Fast XML parsing using Expat
=========================================================
Returns an explanatory string for a given error number *errno*.
-.. function:: ParserCreate([encoding[, namespace_separator]])
+.. function:: ParserCreate(encoding=None, namespace_separator=None)
Creates and returns a new :class:`xmlparser` object. *encoding*, if specified,
must be a string naming the encoding used by the XML data. Expat doesn't
-
.. _python:
***********************
-
:mod:`queue` --- A synchronized queue class
===========================================
guarantee that a subsequent call to put() will not block.
-.. method:: Queue.put(item[, block[, timeout]])
+.. method:: Queue.put(item, block=True, timeout=None)
Put *item* into the queue. If optional args *block* is true and *timeout* is
None (the default), block if necessary until a free slot is available. If
Equivalent to ``put(item, False)``.
-.. method:: Queue.get([block[, timeout]])
+.. method:: Queue.get(block=True, timeout=None)
Remove and return an item from the queue. If optional args *block* is true and
*timeout* is None (the default), block if necessary until an item is available.
-
:mod:`quopri` --- Encode and decode MIME quoted-printable data
==============================================================
sending a graphics file.
-.. function:: decode(input, output[,header])
+.. function:: decode(input, output, header=False)
Decode the contents of the *input* file and write the resulting decoded binary
data to the *output* file. *input* and *output* must either be file objects or
Mail Extensions) Part Two: Message Header Extensions for Non-ASCII Text".
-.. function:: encode(input, output, quotetabs)
+.. function:: encode(input, output, quotetabs, header=False)
Encode the contents of the *input* file and write the resulting quoted-printable
data to the *output* file. *input* and *output* must either be file objects or
``input.readline()`` returns an empty string. *quotetabs* is a flag which
controls whether to encode embedded spaces and tabs; when true it encodes such
embedded whitespace, and when false it leaves them unencoded. Note that spaces
- and tabs appearing at the end of lines are always encoded, as per :rfc:`1521`.
+ and tabs appearing at the end of lines are always encoded, as per
+ :rfc:`1521`. *header* is a flag which controls if spaces are encoded as
+ underscores as per :rfc:`1522`.
-.. function:: decodestring(s[,header])
+.. function:: decodestring(s, header=False)
Like :func:`decode`, except that it accepts a source string and returns the
corresponding decoded string.
-.. function:: encodestring(s[, quotetabs])
+.. function:: encodestring(s, quotetabs=False, header=False)
Like :func:`encode`, except that it accepts a source string and returns the
- corresponding encoded string. *quotetabs* is optional (defaulting to 0), and is
- passed straight through to :func:`encode`.
+ corresponding encoded string. *quotetabs* and *header* are optional
+ (defaulting to ``False``), and are passed straight through to :func:`encode`.
.. seealso::
-
:mod:`random` --- Generate pseudo-random numbers
================================================
-
:mod:`re` --- Regular expression operations
===========================================
form.
-.. function:: compile(pattern[, flags])
+.. function:: compile(pattern, flags=0)
Compile a regular expression pattern into a regular expression object, which
can be used for matching using its :func:`match` and :func:`search` methods,
string.
-.. function:: match(pattern, string[, flags])
+.. function:: match(pattern, string, flags=0)
If zero or more characters at the beginning of *string* match the regular
expression *pattern*, return a corresponding :class:`MatchObject` instance.
instead.
-.. function:: split(pattern, string[, maxsplit=0, flags=0])
+.. function:: split(pattern, string, maxsplit=0, flags=0)
Split *string* by the occurrences of *pattern*. If capturing parentheses are
used in *pattern*, then the text of all groups in the pattern are also returned
Added the optional flags argument.
-.. function:: findall(pattern, string[, flags])
+.. function:: findall(pattern, string, flags=0)
Return all non-overlapping matches of *pattern* in *string*, as a list of
strings. The *string* is scanned left-to-right, and matches are returned in
beginning of another match.
-.. function:: finditer(pattern, string[, flags])
+.. function:: finditer(pattern, string, flags=0)
Return an :term:`iterator` yielding :class:`MatchObject` instances over all
non-overlapping matches for the RE *pattern* in *string*. The *string* is
match.
-.. function:: sub(pattern, repl, string[, count, flags])
+.. function:: sub(pattern, repl, string, count=0, flags=0)
Return the string obtained by replacing the leftmost non-overlapping occurrences
of *pattern* in *string* by the replacement *repl*. If the pattern isn't found,
Added the optional flags argument.
-.. function:: subn(pattern, repl, string[, count, flags])
+.. function:: subn(pattern, repl, string, count=0, flags=0)
Perform the same operation as :func:`sub`, but return a tuple ``(new_string,
number_of_subs_made)``.
:meth:`~RegexObject.match` method.
-.. method:: RegexObject.split(string[, maxsplit=0])
+.. method:: RegexObject.split(string, maxsplit=0)
Identical to the :func:`split` function, using the compiled pattern.
Identical to the :func:`finditer` function, using the compiled pattern.
-.. method:: RegexObject.sub(repl, string[, count=0])
+.. method:: RegexObject.sub(repl, string, count=0)
Identical to the :func:`sub` function, using the compiled pattern.
-.. method:: RegexObject.subn(repl, string[, count=0])
+.. method:: RegexObject.subn(repl, string, count=0)
Identical to the :func:`subn` function, using the compiled pattern.
'c3'
-.. method:: MatchObject.groups([default])
+.. method:: MatchObject.groups(default=None)
Return a tuple containing all the subgroups of the match, from 1 up to however
many groups are in the pattern. The *default* argument is used for groups that
('24', '0')
-.. method:: MatchObject.groupdict([default])
+.. method:: MatchObject.groupdict(default=None)
Return a dictionary containing all the *named* subgroups of the match, keyed by
the subgroup name. The *default* argument is used for groups that did not
{'first_name': 'Malcom', 'last_name': 'Reynolds'}
-.. method:: MatchObject.start([group])
- MatchObject.end([group])
+.. method:: MatchObject.start(group=0)
+ MatchObject.end(group=0)
Return the indices of the start and end of the substring matched by *group*;
*group* defaults to zero (meaning the whole matched substring). Return ``-1`` if
'tony@tiger.net'
-.. method:: MatchObject.span([group])
+.. method:: MatchObject.span(group=0)
For :class:`MatchObject` *m*, return the 2-tuple ``(m.start(group),
m.end(group))``. Note that if *group* did not contribute to the match, this is
-
:mod:`readline` --- GNU readline interface
==========================================
:mod:`reprlib` --- Alternate :func:`repr` implementation
========================================================
-
.. module:: reprlib
:synopsis: Alternate repr() implementation with size limits.
.. sectionauthor:: Fred L. Drake, Jr. <fdrake@acm.org>
-
:mod:`resource` --- Resource usage information
==============================================
-
:mod:`rlcompleter` --- Completion function for GNU readline
===========================================================
The :mod:`runpy` module provides a single function:
-.. function:: run_module(mod_name[, init_globals] [, run_name][, alter_sys])
+.. function:: run_module(mod_name, init_globals=None, run_name=None, alter_sys=False)
Execute the code of the specified module and return the resulting module globals
dictionary. The module's code is first located using the standard import
-
:mod:`select` --- Waiting for I/O completion
============================================
string, as would be printed by the C function :cfunc:`perror`.
-.. function:: epoll([sizehint=-1])
+.. function:: epoll(sizehint=-1)
(Only supported on Linux 2.5.44 and newer.) Returns an edge polling object,
which can be used as Edge or Level Triggered interface for I/O events; see
lots of shared sub-objects. The keys are ordinary strings.
-.. function:: open(filename[, flag='c'[, protocol=None[, writeback=False]]])
+.. function:: open(filename, flag='c', protocol=None, writeback=False)
Open a persistent dictionary. The filename specified is the base filename for
the underlying database. As a side-effect, an extension may be added to the
implementation used.
-.. class:: Shelf(dict[, protocol=None[, writeback=False]])
+.. class:: Shelf(dict, protocol=None, writeback=False)
A subclass of :class:`collections.MutableMapping` which stores pickled values
in the *dict* object.
memory and make sync and close take a long time.
-.. class:: BsdDbShelf(dict[, protocol=None[, writeback=False]])
+.. class:: BsdDbShelf(dict, protocol=None, writeback=False)
A subclass of :class:`Shelf` which exposes :meth:`first`, :meth:`!next`,
:meth:`previous`, :meth:`last` and :meth:`set_location` which are available
as for the :class:`Shelf` class.
-.. class:: DbfilenameShelf(filename[, flag='c'[, protocol=None[, writeback=False]]])
+.. class:: DbfilenameShelf(filename, flag='c', protocol=None, writeback=False)
A subclass of :class:`Shelf` which accepts a *filename* instead of a dict-like
object. The underlying file will be opened using :func:`dbm.open`. By
-
:mod:`shlex` --- Simple lexical analysis
========================================
The :mod:`shlex` module defines the following functions:
-.. function:: split(s[, comments[, posix]])
+.. function:: split(s, comments=False, posix=True)
Split the string *s* using shell-like syntax. If *comments* is :const:`False`
(the default), the parsing of comments in the given string will be disabled
.. note::
- Since the :func:`split` function instantiates a :class:`shlex` instance, passing
- ``None`` for *s* will read the string to split from standard input.
+ Since the :func:`split` function instantiates a :class:`shlex` instance,
+ passing ``None`` for *s* will read the string to split from standard
+ input.
The :mod:`shlex` module defines the following class:
-.. class:: shlex([instream[, infile[, posix]]])
+.. class:: shlex(instream=None, infile=None, posix=False)
A :class:`shlex` instance or subclass instance is a lexical analyzer object.
The initialization argument, if present, specifies where to read characters
:meth:`pop_source` methods.
-.. method:: shlex.push_source(stream[, filename])
+.. method:: shlex.push_source(newstream, newfile=None)
Push an input source stream onto the input stack. If the filename argument is
specified it will later be available for use in error messages. This is the
used internally when the lexer reaches EOF on a stacked input stream.
-.. method:: shlex.error_leader([file[, line]])
+.. method:: shlex.error_leader(infile=None, lineno=None)
This method generates an error message leader in the format of a Unix C compiler
error label; the format is ``'"%s", line %d: '``, where the ``%s`` is replaced
-
:mod:`shutil` --- High-level file operations
============================================
match one of the glob-style *patterns* provided. See the example below.
-.. function:: copytree(src, dst[, symlinks=False[, ignore=None]])
+.. function:: copytree(src, dst, symlinks=False, ignore=None)
Recursively copy an entire directory tree rooted at *src*. The destination
directory, named by *dst*, must not already exist; it will be created as well
ultimate tool.
-.. function:: rmtree(path[, ignore_errors[, onerror]])
+.. function:: rmtree(path, ignore_errors=False, onerror=None)
.. index:: single: directory; deleting
-
:mod:`signal` --- Set handlers for asynchronous events
======================================================
.. data:: ITIMER_REAL
- Decrements interval timer in real time, and delivers :const:`SIGALRM` upon expiration.
+ Decrements interval timer in real time, and delivers :const:`SIGALRM` upon
+ expiration.
.. data:: ITIMER_VIRTUAL
.. function:: siginterrupt(signalnum, flag)
- Change system call restart behaviour: if *flag* is :const:`False`, system calls
- will be restarted when interrupted by signal *signalnum*, otherwise system calls will
- be interrupted. Returns nothing. Availability: Unix (see the man page
- :manpage:`siginterrupt(3)` for further information).
+ Change system call restart behaviour: if *flag* is :const:`False`, system
+ calls will be restarted when interrupted by signal *signalnum*, otherwise
+ system calls will be interrupted. Returns nothing. Availability: Unix (see
+ the man page :manpage:`siginterrupt(3)` for further information).
- Note that installing a signal handler with :func:`signal` will reset the restart
- behaviour to interruptible by implicitly calling :cfunc:`siginterrupt` with a true *flag*
- value for the given signal.
+ Note that installing a signal handler with :func:`signal` will reset the
+ restart behaviour to interruptible by implicitly calling
+ :cfunc:`siginterrupt` with a true *flag* value for the given signal.
.. function:: signal(signalnum, handler)
-
:mod:`site` --- Site-specific configuration hook
================================================
.. versionadded:: 2.7
-XXX Update documentation
-XXX document python -m site --user-base --user-site
+.. XXX Update documentation
+.. XXX document python -m site --user-base --user-site
-
:mod:`smtplib` --- SMTP protocol client
=======================================
Protocol) and :rfc:`1869` (SMTP Service Extensions).
-.. class:: SMTP([host[, port[, local_hostname[, timeout]]]])
+.. class:: SMTP(host='', port=0, local_hostname=None[, timeout])
A :class:`SMTP` instance encapsulates an SMTP connection. It has methods
that support a full repertoire of SMTP and ESMTP operations. If the optional
:meth:`sendmail`, and :meth:`quit` methods. An example is included below.
-.. class:: SMTP_SSL([host[, port[, local_hostname[, keyfile[, certfile[, timeout]]]]]])
+.. class:: SMTP_SSL(host='', port=0, local_hostname=None, keyfile=None, certfile=None[, timeout])
A :class:`SMTP_SSL` instance behaves exactly the same as instances of
:class:`SMTP`. :class:`SMTP_SSL` should be used for situations where SSL is
required from the beginning of the connection and using :meth:`starttls` is
not appropriate. If *host* is not specified, the local host is used. If
- *port* is omitted, the standard SMTP-over-SSL port (465) is used. *keyfile*
+ *port* is zero, the standard SMTP-over-SSL port (465) is used. *keyfile*
and *certfile* are also optional, and can contain a PEM formatted private key
and certificate chain file for the SSL connection. The optional *timeout*
parameter specifies a timeout in seconds for blocking operations like the
will be used).
-.. class:: LMTP([host[, port[, local_hostname]]])
+.. class:: LMTP(host='', port=LMTP_PORT, local_hostname=None)
The LMTP protocol, which is very similar to ESMTP, is heavily based on the
standard SMTP client. It's common to use Unix sockets for LMTP, so our :meth:`connect`
for connection and for all messages sent to and received from the server.
-.. method:: SMTP.connect([host[, port]])
+.. method:: SMTP.connect(host='localhost', port=0)
Connect to a host on a given port. The defaults are to connect to the local
host at the standard SMTP port (25). If the hostname ends with a colon (``':'``)
the constructor if a host is specified during instantiation.
-.. method:: SMTP.docmd(cmd, [, argstring])
+.. method:: SMTP.docmd(cmd, args='')
- Send a command *cmd* to the server. The optional argument *argstring* is simply
+ Send a command *cmd* to the server. The optional argument *args* is simply
concatenated to the command, separated by a space.
This returns a 2-tuple composed of a numeric response code and the actual
:exc:`SMTPServerDisconnected` will be raised.
-.. method:: SMTP.helo([hostname])
+.. method:: SMTP.helo(name='')
Identify yourself to the SMTP server using ``HELO``. The hostname argument
defaults to the fully qualified domain name of the local host.
It will be implicitly called by the :meth:`sendmail` when necessary.
-.. method:: SMTP.ehlo([hostname])
+.. method:: SMTP.ehlo(name='')
Identify yourself to an ESMTP server using ``EHLO``. The hostname argument
defaults to the fully qualified domain name of the local host. Examine the
No suitable authentication method was found.
-.. method:: SMTP.starttls([keyfile[, certfile]])
+.. method:: SMTP.starttls(keyfile=None, certfile=None)
Put the SMTP connection in TLS (Transport Layer Security) mode. All SMTP
commands that follow will be encrypted. You should then call :meth:`ehlo`
SSL/TLS support is not available to your python interpreter.
-.. method:: SMTP.sendmail(from_addr, to_addrs, msg[, mail_options, rcpt_options])
+.. method:: SMTP.sendmail(from_addr, to_addrs, msg, mail_options=[], rcpt_options=[])
Send mail. The required arguments are an :rfc:`822` from-address string, a list
of :rfc:`822` to-address strings (a bare string will be treated as a list with 1
-
:mod:`sndhdr` --- Determine type of sound file
==============================================
-
:mod:`socket` --- Low-level networking interface
================================================
-
:mod:`socketserver` --- A framework for network servers
=======================================================