To do just the former:
-.. function:: compile_command(source[, filename[, symbol]])
+.. function:: compile_command(source, filename="<input>", symbol="single")
Tries to compile *source*, which should be a string of Python code and return a
code object if *source* is valid Python code. In that case, the filename
:class:`deque` objects
----------------------
-.. class:: deque([iterable[, maxlen]])
+.. class:: deque([iterable, [maxlen]])
Returns a new deque object initialized left-to-right (using :meth:`append`) with
data from *iterable*. If *iterable* is not specified, the new deque is empty.
self-documenting code. They can be used wherever regular tuples are used, and
they add the ability to access fields by name instead of position index.
-.. function:: namedtuple(typename, field_names, [verbose], [rename])
+.. function:: namedtuple(typename, field_names, verbose=False, rename=False)
Returns a new tuple subclass named *typename*. The new subclass is used to
create tuple-like objects that have fields accessible by attribute lookup as
expression argument. All files that match the expression will be skipped.
-.. function:: compile_dir(dir[, maxlevels[, ddir[, force[, rx[, quiet]]]]])
+.. function:: compile_dir(dir, maxlevels=10, ddir=None, force=False, rx=None, quiet=False)
Recursively descend the directory tree named by *dir*, compiling all :file:`.py`
files along the way. The *maxlevels* parameter is used to limit the depth of
operation.
-.. function:: compile_path([skip_curdir[, maxlevels[, force]]])
+.. function:: compile_path(skip_curdir=True, maxlevels=0, force=False)
Byte-compile all the :file:`.py` files found along ``sys.path``. If
*skip_curdir* is true (the default), the current directory is not included in
write-back, as will be the keys within each section.
-.. class:: RawConfigParser([defaults[, dict_type]])
+.. class:: RawConfigParser(defaults=None, dict_type=collections.OrderedDict)
The basic configuration object. When *defaults* is given, it is initialized
into the dictionary of intrinsic defaults. When *dict_type* is given, it will
The default *dict_type* is :class:`collections.OrderedDict`.
-.. class:: ConfigParser([defaults[, dict_type]])
+.. class:: ConfigParser(defaults=None, dict_type=collections.OrderedDict)
Derived class of :class:`RawConfigParser` that implements the magical
interpolation feature and adds optional arguments to the :meth:`get` and
The default *dict_type* is :class:`collections.OrderedDict`.
-.. class:: SafeConfigParser([defaults[, dict_type]])
+.. class:: SafeConfigParser(defaults=None, dict_type=collections.OrderedDict)
Derived class of :class:`ConfigParser` that implements a more-sane variant of
the magical interpolation feature. This implementation is more predictable as
config.read(['site.cfg', os.path.expanduser('~/.myapp.cfg')])
-.. method:: RawConfigParser.readfp(fp[, filename])
+.. method:: RawConfigParser.readfp(fp, filename=None)
Read and parse configuration data from the file or file-like object in *fp*
(only the :meth:`readline` method is used). If *filename* is omitted and *fp*
:class:`RawConfigParser` interface, adding some optional arguments.
-.. method:: ConfigParser.get(section, option[, raw[, vars]])
+.. method:: ConfigParser.get(section, option, raw=False, vars=None)
Get an *option* value for the named *section*. All the ``'%'`` interpolations
are expanded in the return values, based on the defaults passed into the
is true.
-.. method:: ConfigParser.items(section[, raw[, vars]])
+.. method:: ConfigParser.items(section, raw=False, vars=None)
Return a list of ``(name, value)`` pairs for each option in the given *section*.
Optional arguments have the same meaning as for the :meth:`get` method.
built-in namespace. They are useful for the interactive interpreter shell and
should not be used in programs.
-.. data:: quit([code=None])
- exit([code=None])
+.. data:: 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 :exc:`SystemExit` with the
hence not valid as a constructor), raises :exc:`TypeError`.
-.. function:: pickle(type, function[, constructor])
+.. function:: pickle(type, function, constructor=None)
Declares that *function* should be used as a "reduction" function for objects
of type *type*. *function* should return either a string or a tuple
The :mod:`csv` module defines the following functions:
-.. function:: reader(csvfile[, dialect='excel'][, fmtparam])
+.. function:: reader(csvfile, dialect='excel', **fmtparams)
Return a reader object which will iterate over lines in the given *csvfile*.
*csvfile* can be any object which supports the :term:`iterator` protocol and returns a
*dialect* parameter can be given which is used to define a set of parameters
specific to a particular CSV dialect. It may be an instance of a subclass of
the :class:`Dialect` class or one of the strings returned by the
- :func:`list_dialects` function. The other optional *fmtparam* keyword arguments
+ :func:`list_dialects` function. The other optional *fmtparams* keyword arguments
can be given to override individual formatting parameters in the current
dialect. For full details about the dialect and formatting parameters, see
section :ref:`csv-fmt-params`.
Spam, Lovely Spam, Wonderful Spam
-.. function:: writer(csvfile[, dialect='excel'][, fmtparam])
+.. function:: writer(csvfile, dialect='excel', **fmtparams)
Return a writer object responsible for converting the user's data into delimited
strings on the given file-like object. *csvfile* can be any object with a
parameter can be given which is used to define a set of parameters specific to a
particular CSV dialect. It may be an instance of a subclass of the
:class:`Dialect` class or one of the strings returned by the
- :func:`list_dialects` function. The other optional *fmtparam* keyword arguments
+ :func:`list_dialects` function. The other optional *fmtparams* keyword arguments
can be given to override individual formatting parameters in the current
dialect. For full details about the dialect and formatting parameters, see
section :ref:`csv-fmt-params`. To make it
>>> spamWriter.writerow(['Spam', 'Lovely Spam', 'Wonderful Spam'])
-.. function:: register_dialect(name[, dialect][, fmtparam])
+.. function:: register_dialect(name[, dialect], **fmtparams)
Associate *dialect* with *name*. *name* must be a string. The
dialect can be specified either by passing a sub-class of :class:`Dialect`, or
- by *fmtparam* keyword arguments, or both, with keyword arguments overriding
+ by *fmtparams* keyword arguments, or both, with keyword arguments overriding
parameters of the dialect. For full details about the dialect and formatting
parameters, see section :ref:`csv-fmt-params`.
The :mod:`csv` module defines the following classes:
-.. class:: DictReader(csvfile[, fieldnames=None[, restkey=None[, restval=None[, dialect='excel'[, *args, **kwds]]]]])
+.. class:: DictReader(csvfile, fieldnames=None, restkey=None, restval=None, dialect='excel', *args, **kwds)
Create an object which operates like a regular reader but maps the information
read into a dict whose keys are given by the optional *fieldnames* parameter.
arguments are passed to the underlying :class:`reader` instance.
-.. class:: DictWriter(csvfile, fieldnames[, restval=''[, extrasaction='raise'[, dialect='excel'[, *args, **kwds]]]])
+.. class:: DictWriter(csvfile, fieldnames, restval='', extrasaction='raise', dialect='excel', *args, **kwds)
Create an object which operates like a regular writer but maps dictionaries onto
output rows. The *fieldnames* parameter identifies the order in which values in
The :class:`Sniffer` class provides two methods:
- .. method:: sniff(sample[, delimiters=None])
+ .. method:: sniff(sample, delimiters=None)
Analyze the given *sample* and return a :class:`Dialect` subclass
reflecting the parameters found. If the optional *delimiters* parameter
capability, or is canceled or absent from the terminal description.
-.. function:: tparm(str[,...])
+.. function:: tparm(str[, ...])
Instantiates the string *str* with the supplied parameters, where *str* should
be a parameterized string obtained from the terminfo database. E.g.
dates or times.
-.. class:: timedelta([days[, seconds[, microseconds[, milliseconds[, minutes[, hours[, weeks]]]]]]])
+.. class:: timedelta(days=0, seconds=0, microseconds=0, milliseconds=0, minutes=0, hours=0, weeks=0)
All arguments are optional and default to ``0``. Arguments may be integers
or floats, and may be positive or negative.
Constructor:
-.. class:: datetime(year, month, day[, hour[, minute[, second[, microsecond[, tzinfo]]]]])
+.. class:: datetime(year, month, day, hour=0, minute=0, second=0, microsecond=0, tzinfo=None)
The year, month and day arguments are required. *tzinfo* may be ``None``, or an
instance of a :class:`tzinfo` subclass. The remaining arguments may be integers,
:meth:`fromtimestamp`.
-.. method:: datetime.now([tz])
+.. method:: datetime.now(tz=None)
Return the current local date and time. If optional argument *tz* is ``None``
or not specified, this is like :meth:`today`, but, if possible, supplies more
:class:`datetime` object. See also :meth:`now`.
-.. method:: datetime.fromtimestamp(timestamp[, tz])
+.. method:: datetime.fromtimestamp(timestamp, tz=None)
Return the local date and time corresponding to the POSIX timestamp, such as is
returned by :func:`time.time`. If optional argument *tz* is ``None`` or not
``self.date().isocalendar()``.
-.. method:: datetime.isoformat([sep])
+.. method:: datetime.isoformat(sep='T')
Return a string representing the date and time in ISO 8601 format,
YYYY-MM-DDTHH:MM:SS.mmmmmm or, if :attr:`microsecond` is 0,
day, and subject to adjustment via a :class:`tzinfo` object.
-.. class:: time(hour[, minute[, second[, microsecond[, tzinfo]]]])
+.. class:: time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None)
All arguments are optional. *tzinfo* may be ``None``, or an instance of a
:class:`tzinfo` subclass. The remaining arguments may be integers, in the
name, such as ``'dbm.ndbm'`` or ``'dbm.gnu'``.
-.. function:: open(filename[, flag[, mode]])
+.. function:: open(filename, flag='r', mode=0o666)
Open the database file *filename* and return a corresponding object.
raised for general mapping errors like specifying an incorrect key.
-.. function:: open(filename, [flag, [mode]])
+.. function:: open(filename[, flag[, mode]])
Open a ``gdbm`` database and return a :class:`gdbm` object. The *filename*
argument is the name of the database file.
---------------
-.. class:: Decimal([value [, context]])
+.. class:: Decimal(value="0", context=None)
Construct a new :class:`Decimal` object based from *value*.
The constructor for this class is:
- .. function:: __init__([tabsize][, wrapcolumn][, linejunk][, charjunk])
+ .. method:: __init__(tabsize=8, wrapcolumn=None, linejunk=None, charjunk=IS_CHARACTER_JUNK)
Initializes instance of :class:`HtmlDiff`.
The following methods are public:
-
- .. function:: make_file(fromlines, tolines [, fromdesc][, todesc][, context][, numlines])
+ .. method:: make_file(fromlines, tolines, fromdesc='', todesc='', context=False, numlines=5)
Compares *fromlines* and *tolines* (lists of strings) and returns a string which
is a complete HTML file containing a table showing line by line differences with
the next difference highlight at the top of the browser without any leading
context).
-
- .. function:: make_table(fromlines, tolines [, fromdesc][, todesc][, context][, numlines])
+ .. method:: make_table(fromlines, tolines, fromdesc='', todesc='', context=False, numlines=5)
Compares *fromlines* and *tolines* (lists of strings) and returns a string which
is a complete HTML table showing line by line differences with inter-line and
contains a good example of its use.
-.. function:: context_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
+.. function:: context_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in context diff format.
See :ref:`difflib-interface` for a more detailed example.
-.. function:: get_close_matches(word, possibilities[, n][, cutoff])
+.. function:: get_close_matches(word, possibilities, n=3, cutoff=0.6)
Return a list of the best "good enough" matches. *word* is a sequence for which
close matches are desired (typically a string), and *possibilities* is a list of
['except']
-.. function:: ndiff(a, b[, linejunk][, charjunk])
+.. function:: ndiff(a, b, linejunk=None, charjunk=IS_CHARACTER_JUNK)
Compare *a* and *b* (lists of strings); return a :class:`Differ`\ -style
delta (a :term:`generator` generating the delta lines).
emu
-.. function:: unified_diff(a, b[, fromfile][, tofile][, fromfiledate][, tofiledate][, n][, lineterm])
+.. function:: unified_diff(a, b, fromfile='', tofile='', fromfiledate='', tofiledate='', n=3, lineterm='\\n')
Compare *a* and *b* (lists of strings); return a delta (a :term:`generator`
generating the delta lines) in unified diff format.
The :class:`SequenceMatcher` class has this constructor:
-.. class:: SequenceMatcher([isjunk[, a[, b]]])
+.. class:: SequenceMatcher(isjunk=None, a='', b='')
Optional argument *isjunk* must be ``None`` (the default) or a one-argument
function that takes a sequence element and returns true if and only if the
insert a[6:6] () b[5:6] (f)
- .. method:: get_grouped_opcodes([n])
+ .. method:: get_grouped_opcodes(n=3)
Return a :term:`generator` of groups with up to *n* lines of context.
The :class:`Differ` class has this constructor:
-.. class:: Differ([linejunk[, charjunk]])
+.. class:: Differ(linejunk=None, charjunk=None)
Optional keyword parameters *linejunk* and *charjunk* are for filter functions
(or ``None``):
The :mod:`dis` module defines the following functions and constants:
-.. function:: dis([bytesource])
+.. function:: dis(x=None)
- Disassemble the *bytesource* object. *bytesource* can denote either a module, a
+ Disassemble the *x* object. *x* can denote either a module, a
class, a method, a function, or a code object. For a module, it disassembles
all functions. For a class, it disassembles all methods. For a single code
sequence, it prints one line per bytecode instruction. If no object is
provided, it disassembles the last traceback.
-.. function:: distb([tb])
+.. function:: distb(tb=None)
Disassembles the top-of-stack function of a traceback, using the last traceback
if none was passed. The instruction causing the exception is indicated.
-.. function:: disassemble(code[, lasti])
+.. function:: disassemble(code, lasti=-1)
+ disco(code, lasti=-1)
Disassembles a code object, indicating the last instruction if *lasti* was
provided. The output is divided in the following columns:
constant values, branch targets, and compare operators.
-.. function:: disco(code[, lasti])
-
- A synonym for :func:`disassemble`. It is more convenient to type, and kept
- for compatibility with earlier Python releases.
-
-
.. function:: findlinestarts(code)
This generator function uses the ``co_firstlineno`` and ``co_lnotab``
and :ref:`doctest-simple-testfile`.
-.. function:: testfile(filename[, module_relative][, name][, package][, globs][, verbose][, report][, optionflags][, extraglobs][, raise_on_error][, parser][, encoding])
+.. function:: testfile(filename, module_relative=True, name=None, package=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, parser=DocTestParser(), encoding=None)
All arguments except *filename* are optional, and should be specified in keyword
form.
convert the file to unicode.
-.. function:: testmod([m][, name][, globs][, verbose][, report][, optionflags][, extraglobs][, raise_on_error][, exclude_empty])
+.. function:: testmod(m=None, name=None, globs=None, verbose=None, report=True, optionflags=0, extraglobs=None, raise_on_error=False, exclude_empty=False)
All arguments are optional, and all except for *m* should be specified in
keyword form.
deprecate it, but it's rarely useful:
-.. function:: run_docstring_examples(f, globs[, verbose][, name][, compileflags][, optionflags])
+.. function:: run_docstring_examples(f, globs, verbose=False, name="NoName", compileflags=None, optionflags=0)
Test examples associated with object *f*; for example, *f* may be a module,
function, or class object.
from text files and modules with doctests:
-.. function:: DocFileSuite(*paths, [module_relative][, package][, setUp][, tearDown][, globs][, optionflags][, parser][, encoding])
+.. function:: DocFileSuite(*paths, module_relative=True, package=None, setUp=None, tearDown=None, globs=None, optionflags=0, parser=DocTestParser(), encoding=None)
Convert doctest tests from one or more text files to a
:class:`unittest.TestSuite`.
from a text file using :func:`DocFileSuite`.
-.. function:: DocTestSuite([module][, globs][, extraglobs][, test_finder][, setUp][, tearDown][, checker])
+.. function:: DocTestSuite(module=None, globs=None, extraglobs=None, test_finder=None, setUp=None, tearDown=None, checker=None)
Convert doctest tests for a module to a :class:`unittest.TestSuite`.
^^^^^^^^^^^^^^^
-.. class:: Example(source, want[, exc_msg][, lineno][, indent][, options])
+.. class:: Example(source, want, exc_msg=None, lineno=0, indent=0, options=None)
A single interactive example, consisting of a Python statement and its expected
output. The constructor arguments are used to initialize the member variables
^^^^^^^^^^^^^^^^^^^^^
-.. class:: DocTestFinder([verbose][, parser][, recurse][, exclude_empty])
+.. class:: DocTestFinder(verbose=False, parser=DocTestParser(), recurse=True, exclude_empty=True)
A processing class used to extract the :class:`DocTest`\ s that are relevant to
a given object, from its docstring and the docstrings of its contained objects.
information.
- .. method:: get_examples(string[, name])
+ .. method:: get_examples(string, name='<string>')
Extract all doctest examples from the given string, and return them as a list
of :class:`Example` objects. Line numbers are 0-based. The optional argument
*name* is a name identifying this string, and is only used for error messages.
- .. method:: parse(string[, name])
+ .. method:: parse(string, name='<string>')
Divide the given string into examples and intervening text, and return them as
a list of alternating :class:`Example`\ s and strings. Line numbers for the
^^^^^^^^^^^^^^^^^^^^^
-.. class:: DocTestRunner([checker][, verbose][, optionflags])
+.. class:: DocTestRunner(checker=None, verbose=None, optionflags=0)
A processing class used to execute and verify the interactive examples in a
:class:`DocTest`.
output function that was passed to :meth:`DocTestRunner.run`.
- .. method:: run(test[, compileflags][, out][, clear_globs])
+ .. method:: run(test, compileflags=None, out=None, clear_globs=True)
Run the examples in *test* (a :class:`DocTest` object), and display the
results using the writer function *out*.
:meth:`DocTestRunner.report_\*` methods.
- .. method:: summarize([verbose])
+ .. method:: summarize(verbose=None)
Print a summary of all the test cases that have been run by this DocTestRunner,
and return a :term:`named tuple` ``TestResults(failed, attempted)``.
converted to code, and the rest placed in comments.
-.. function:: debug(module, name[, pm])
+.. function:: debug(module, name, pm=False)
Debug the doctests for an object.
passing an appropriate :func:`exec` call to :func:`pdb.run`.
-.. function:: debug_src(src[, pm][, globs])
+.. function:: debug_src(src, pm=False, globs=None)
Debug the doctests in a string.
doctest!) for more details:
-.. class:: DebugRunner([checker][, verbose][, optionflags])
+.. class:: DebugRunner(checker=None, verbose=None, optionflags=0)
A subclass of :class:`DocTestRunner` that raises an exception as soon as a
failure is encountered. If an unexpected exception occurs, an