mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Fix a whole load of markup glitches introduced mostly by the converter.
Many thanks to Tim Hatch for finding them, and thanks to Emacs for making it easy to fix them :)
This commit is contained in:
parent
8809f4163c
commit
0dc5e041ad
@ -182,9 +182,9 @@ of. If :class:`A` and :class:`B` are class objects, :class:`B` is a subclass of
|
||||
either is not a class object, a more general mechanism is used to determine the
|
||||
class relationship of the two objects. When testing if *B* is a subclass of
|
||||
*A*, if *A* is *B*, :cfunc:`PyObject_IsSubclass` returns true. If *A* and *B*
|
||||
are different objects, *B*'s :attr:`__bases__` attribute is searched in a depth-
|
||||
first fashion for *A* --- the presence of the :attr:`__bases__` attribute is
|
||||
considered sufficient for this determination.
|
||||
are different objects, *B*'s :attr:`__bases__` attribute is searched in a
|
||||
depth-first fashion for *A* --- the presence of the :attr:`__bases__` attribute
|
||||
is considered sufficient for this determination.
|
||||
|
||||
|
||||
.. cfunction:: int PyObject_IsSubclass(PyObject *derived, PyObject *cls)
|
||||
|
@ -1662,11 +1662,9 @@ They all return *NULL* or ``-1`` if an exception occurs.
|
||||
|
||||
Rich compare two unicode strings and return one of the following:
|
||||
|
||||
* ``NULL`` in case an exception was raised
|
||||
|
||||
* :const:`Py_True` or :const:`Py_False` for successful comparisons
|
||||
|
||||
* :const:`Py_NotImplemented` in case the type combination is unknown
|
||||
* ``NULL`` in case an exception was raised
|
||||
* :const:`Py_True` or :const:`Py_False` for successful comparisons
|
||||
* :const:`Py_NotImplemented` in case the type combination is unknown
|
||||
|
||||
Note that :const:`Py_EQ` and :const:`Py_NE` comparisons can cause a
|
||||
:exc:`UnicodeWarning` in case the conversion of the arguments to Unicode fails
|
||||
@ -2411,7 +2409,7 @@ change in future releases of Python.
|
||||
|
||||
.. index:: single: EOFError (built-in exception)
|
||||
|
||||
Equivalent to ``p.readline([*n*])``, this function reads one line from the
|
||||
Equivalent to ``p.readline([n])``, this function reads one line from the
|
||||
object *p*. *p* may be a file object or any object with a :meth:`readline`
|
||||
method. If *n* is ``0``, exactly one line is read, regardless of the length of
|
||||
the line. If *n* is greater than ``0``, no more than *n* bytes will be read
|
||||
@ -2773,8 +2771,9 @@ sentinel value is returned.
|
||||
|
||||
.. cvar:: PyTypeObject PySeqIter_Type
|
||||
|
||||
Type object for iterator objects returned by :cfunc:`PySeqIter_New` and the one-
|
||||
argument form of the :func:`iter` built-in function for built-in sequence types.
|
||||
Type object for iterator objects returned by :cfunc:`PySeqIter_New` and the
|
||||
one-argument form of the :func:`iter` built-in function for built-in sequence
|
||||
types.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
@ -2965,14 +2964,14 @@ as much as it can.
|
||||
|
||||
.. cfunction:: PyObject* PyWeakref_NewRef(PyObject *ob, PyObject *callback)
|
||||
|
||||
Return a weak reference object for the object *ob*. This will always return a
|
||||
new reference, but is not guaranteed to create a new object; an existing
|
||||
Return a weak reference object for the object *ob*. This will always return
|
||||
a new reference, but is not guaranteed to create a new object; an existing
|
||||
reference object may be returned. The second parameter, *callback*, can be a
|
||||
callable object that receives notification when *ob* is garbage collected; it
|
||||
should accept a single parameter, which will be the weak reference object
|
||||
itself. *callback* may also be ``None`` or *NULL*. If *ob* is not a weakly-
|
||||
referencable object, or if *callback* is not callable, ``None``, or *NULL*, this
|
||||
will return *NULL* and raise :exc:`TypeError`.
|
||||
itself. *callback* may also be ``None`` or *NULL*. If *ob* is not a
|
||||
weakly-referencable object, or if *callback* is not callable, ``None``, or
|
||||
*NULL*, this will return *NULL* and raise :exc:`TypeError`.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
@ -2981,12 +2980,12 @@ as much as it can.
|
||||
|
||||
Return a weak reference proxy object for the object *ob*. This will always
|
||||
return a new reference, but is not guaranteed to create a new object; an
|
||||
existing proxy object may be returned. The second parameter, *callback*, can be
|
||||
a callable object that receives notification when *ob* is garbage collected; it
|
||||
should accept a single parameter, which will be the weak reference object
|
||||
itself. *callback* may also be ``None`` or *NULL*. If *ob* is not a weakly-
|
||||
referencable object, or if *callback* is not callable, ``None``, or *NULL*, this
|
||||
will return *NULL* and raise :exc:`TypeError`.
|
||||
existing proxy object may be returned. The second parameter, *callback*, can
|
||||
be a callable object that receives notification when *ob* is garbage
|
||||
collected; it should accept a single parameter, which will be the weak
|
||||
reference object itself. *callback* may also be ``None`` or *NULL*. If *ob*
|
||||
is not a weakly-referencable object, or if *callback* is not callable,
|
||||
``None``, or *NULL*, this will return *NULL* and raise :exc:`TypeError`.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
|
@ -102,15 +102,16 @@ Initialization, Finalization, and Threads
|
||||
``sys.stdout`` and ``sys.stderr`` (however these refer to the same underlying
|
||||
:ctype:`FILE` structures in the C library).
|
||||
|
||||
The return value points to the first thread state created in the new sub-
|
||||
interpreter. This thread state is made in the current thread state. Note that
|
||||
no actual thread is created; see the discussion of thread states below. If
|
||||
creation of the new interpreter is unsuccessful, *NULL* is returned; no
|
||||
exception is set since the exception state is stored in the current thread state
|
||||
and there may not be a current thread state. (Like all other Python/C API
|
||||
functions, the global interpreter lock must be held before calling this function
|
||||
and is still held when it returns; however, unlike most other Python/C API
|
||||
functions, there needn't be a current thread state on entry.)
|
||||
The return value points to the first thread state created in the new
|
||||
sub-interpreter. This thread state is made in the current thread state.
|
||||
Note that no actual thread is created; see the discussion of thread states
|
||||
below. If creation of the new interpreter is unsuccessful, *NULL* is
|
||||
returned; no exception is set since the exception state is stored in the
|
||||
current thread state and there may not be a current thread state. (Like all
|
||||
other Python/C API functions, the global interpreter lock must be held before
|
||||
calling this function and is still held when it returns; however, unlike most
|
||||
other Python/C API functions, there needn't be a current thread state on
|
||||
entry.)
|
||||
|
||||
.. index::
|
||||
single: Py_Finalize()
|
||||
@ -169,15 +170,15 @@ Initialization, Finalization, and Threads
|
||||
single: main()
|
||||
single: Py_GetPath()
|
||||
|
||||
This function should be called before :cfunc:`Py_Initialize` is called for the
|
||||
first time, if it is called at all. It tells the interpreter the value of the
|
||||
``argv[0]`` argument to the :cfunc:`main` function of the program. This is used
|
||||
by :cfunc:`Py_GetPath` and some other functions below to find the Python run-
|
||||
time libraries relative to the interpreter executable. The default value is
|
||||
``'python'``. The argument should point to a zero-terminated character string
|
||||
in static storage whose contents will not change for the duration of the
|
||||
program's execution. No code in the Python interpreter will change the contents
|
||||
of this storage.
|
||||
This function should be called before :cfunc:`Py_Initialize` is called for
|
||||
the first time, if it is called at all. It tells the interpreter the value
|
||||
of the ``argv[0]`` argument to the :cfunc:`main` function of the program.
|
||||
This is used by :cfunc:`Py_GetPath` and some other functions below to find
|
||||
the Python run-time libraries relative to the interpreter executable. The
|
||||
default value is ``'python'``. The argument should point to a
|
||||
zero-terminated character string in static storage whose contents will not
|
||||
change for the duration of the program's execution. No code in the Python
|
||||
interpreter will change the contents of this storage.
|
||||
|
||||
|
||||
.. cfunction:: char* Py_GetProgramName()
|
||||
@ -376,12 +377,12 @@ Thread State and the Global Interpreter Lock
|
||||
single: interpreter lock
|
||||
single: lock, interpreter
|
||||
|
||||
The Python interpreter is not fully thread safe. In order to support multi-
|
||||
threaded Python programs, there's a global lock that must be held by the current
|
||||
thread before it can safely access Python objects. Without the lock, even the
|
||||
simplest operations could cause problems in a multi-threaded program: for
|
||||
example, when two threads simultaneously increment the reference count of the
|
||||
same object, the reference count could end up being incremented only once
|
||||
The Python interpreter is not fully thread safe. In order to support
|
||||
multi-threaded Python programs, there's a global lock that must be held by the
|
||||
current thread before it can safely access Python objects. Without the lock,
|
||||
even the simplest operations could cause problems in a multi-threaded program:
|
||||
for example, when two threads simultaneously increment the reference count of
|
||||
the same object, the reference count could end up being incremented only once
|
||||
instead of twice.
|
||||
|
||||
.. index:: single: setcheckinterval() (in module sys)
|
||||
|
@ -70,7 +70,7 @@ the installation directory specified to the installer.
|
||||
|
||||
To include the headers, place both directories (if different) on your compiler's
|
||||
search path for includes. Do *not* place the parent directories on the search
|
||||
path and then use ``#include <python|version|/Python.h>``; this will break on
|
||||
path and then use ``#include <pythonX.Y/Python.h>``; this will break on
|
||||
multi-platform builds since the platform independent headers under
|
||||
:envvar:`prefix` include the platform specific headers from
|
||||
:envvar:`exec_prefix`.
|
||||
@ -402,16 +402,16 @@ takes care of transferring it to ``sys.exc_type`` and friends.
|
||||
|
||||
.. index:: single: exc_info() (in module sys)
|
||||
|
||||
Note that starting with Python 1.5, the preferred, thread-safe way to access
|
||||
the exception state from Python code is to call the function
|
||||
:func:`sys.exc_info`, which returns the per-thread exception state for Python
|
||||
code. Also, the semantics of both ways to access the exception state have
|
||||
changed so that a function which catches an exception will save and restore its
|
||||
thread's exception state so as to preserve the exception state of its caller.
|
||||
This prevents common bugs in exception handling code caused by an innocent-
|
||||
looking function overwriting the exception being handled; it also reduces the
|
||||
often unwanted lifetime extension for objects that are referenced by the stack
|
||||
frames in the traceback.
|
||||
Note that starting with Python 1.5, the preferred, thread-safe way to access the
|
||||
exception state from Python code is to call the function :func:`sys.exc_info`,
|
||||
which returns the per-thread exception state for Python code. Also, the
|
||||
semantics of both ways to access the exception state have changed so that a
|
||||
function which catches an exception will save and restore its thread's exception
|
||||
state so as to preserve the exception state of its caller. This prevents common
|
||||
bugs in exception handling code caused by an innocent-looking function
|
||||
overwriting the exception being handled; it also reduces the often unwanted
|
||||
lifetime extension for objects that are referenced by the stack frames in the
|
||||
traceback.
|
||||
|
||||
As a general principle, a function that calls another function to perform some
|
||||
task should check whether the called function raised an exception, and if so,
|
||||
@ -536,13 +536,13 @@ slightly different), :cfunc:`Py_Initialize` calculates the module search path
|
||||
based upon its best guess for the location of the standard Python interpreter
|
||||
executable, assuming that the Python library is found in a fixed location
|
||||
relative to the Python interpreter executable. In particular, it looks for a
|
||||
directory named :file:`lib/python|version|` relative to the parent directory
|
||||
directory named :file:`lib/python{X.Y}` relative to the parent directory
|
||||
where the executable named :file:`python` is found on the shell command search
|
||||
path (the environment variable :envvar:`PATH`).
|
||||
|
||||
For instance, if the Python executable is found in
|
||||
:file:`/usr/local/bin/python`, it will assume that the libraries are in
|
||||
:file:`/usr/local/lib/python|version|`. (In fact, this particular path is also
|
||||
:file:`/usr/local/lib/python{X.Y}`. (In fact, this particular path is also
|
||||
the "fallback" location, used when no executable file named :file:`python` is
|
||||
found along :envvar:`PATH`.) The user can override this behavior by setting the
|
||||
environment variable :envvar:`PYTHONHOME`, or insert additional directories in
|
||||
@ -594,9 +594,9 @@ frequently-used builds will be described in the remainder of this section.
|
||||
Compiling the interpreter with the :cmacro:`Py_DEBUG` macro defined produces
|
||||
what is generally meant by "a debug build" of Python. :cmacro:`Py_DEBUG` is
|
||||
enabled in the Unix build by adding :option:`--with-pydebug` to the
|
||||
:file:`configure` command. It is also implied by the presence of the not-
|
||||
Python-specific :cmacro:`_DEBUG` macro. When :cmacro:`Py_DEBUG` is enabled in
|
||||
the Unix build, compiler optimization is disabled.
|
||||
:file:`configure` command. It is also implied by the presence of the
|
||||
not-Python-specific :cmacro:`_DEBUG` macro. When :cmacro:`Py_DEBUG` is enabled
|
||||
in the Unix build, compiler optimization is disabled.
|
||||
|
||||
In addition to the reference count debugging described below, the following
|
||||
extra checks are performed:
|
||||
|
@ -480,10 +480,10 @@ type objects) *must* have the :attr:`ob_size` field.
|
||||
The basic size does not include the GC header size (this is new in Python 2.2;
|
||||
in 2.1 and 2.0, the GC header size was included in :attr:`tp_basicsize`).
|
||||
|
||||
These fields are inherited separately by subtypes. If the base type has a non-
|
||||
zero :attr:`tp_itemsize`, it is generally not safe to set :attr:`tp_itemsize` to
|
||||
a different non-zero value in a subtype (though this depends on the
|
||||
implementation of the base type).
|
||||
These fields are inherited separately by subtypes. If the base type has a
|
||||
non-zero :attr:`tp_itemsize`, it is generally not safe to set
|
||||
:attr:`tp_itemsize` to a different non-zero value in a subtype (though this
|
||||
depends on the implementation of the base type).
|
||||
|
||||
A note about alignment: if the variable items require a particular alignment,
|
||||
this should be taken care of by the value of :attr:`tp_basicsize`. Example:
|
||||
|
@ -484,13 +484,13 @@ variable(s) whose address should be passed.
|
||||
Unicode into a character buffer. It only works for encoded data without embedded
|
||||
NUL bytes.
|
||||
|
||||
This format requires two arguments. The first is only used as input, and must
|
||||
be a :ctype:`const char\*` which points to the name of an encoding as a NUL-
|
||||
terminated string, or *NULL*, in which case the default encoding is used. An
|
||||
exception is raised if the named encoding is not known to Python. The second
|
||||
argument must be a :ctype:`char\*\*`; the value of the pointer it references
|
||||
will be set to a buffer with the contents of the argument text. The text will
|
||||
be encoded in the encoding specified by the first argument.
|
||||
This format requires two arguments. The first is only used as input, and
|
||||
must be a :ctype:`const char\*` which points to the name of an encoding as a
|
||||
NUL-terminated string, or *NULL*, in which case the default encoding is used.
|
||||
An exception is raised if the named encoding is not known to Python. The
|
||||
second argument must be a :ctype:`char\*\*`; the value of the pointer it
|
||||
references will be set to a buffer with the contents of the argument text.
|
||||
The text will be encoded in the encoding specified by the first argument.
|
||||
|
||||
:cfunc:`PyArg_ParseTuple` will allocate a buffer of the needed size, copy the
|
||||
encoded data into this buffer and adjust *\*buffer* to reference the newly
|
||||
@ -508,14 +508,14 @@ variable(s) whose address should be passed.
|
||||
input data which contains NUL characters.
|
||||
|
||||
It requires three arguments. The first is only used as input, and must be a
|
||||
:ctype:`const char\*` which points to the name of an encoding as a NUL-
|
||||
terminated string, or *NULL*, in which case the default encoding is used. An
|
||||
exception is raised if the named encoding is not known to Python. The second
|
||||
argument must be a :ctype:`char\*\*`; the value of the pointer it references
|
||||
will be set to a buffer with the contents of the argument text. The text will
|
||||
be encoded in the encoding specified by the first argument. The third argument
|
||||
must be a pointer to an integer; the referenced integer will be set to the
|
||||
number of bytes in the output buffer.
|
||||
:ctype:`const char\*` which points to the name of an encoding as a
|
||||
NUL-terminated string, or *NULL*, in which case the default encoding is used.
|
||||
An exception is raised if the named encoding is not known to Python. The
|
||||
second argument must be a :ctype:`char\*\*`; the value of the pointer it
|
||||
references will be set to a buffer with the contents of the argument text.
|
||||
The text will be encoded in the encoding specified by the first argument.
|
||||
The third argument must be a pointer to an integer; the referenced integer
|
||||
will be set to the number of bytes in the output buffer.
|
||||
|
||||
There are two modes of operation:
|
||||
|
||||
@ -966,14 +966,14 @@ avoid truncation exceeds *size* by more than 512 bytes, Python aborts with a
|
||||
The return value (*rv*) for these functions should be interpreted as follows:
|
||||
|
||||
* When ``0 <= rv < size``, the output conversion was successful and *rv*
|
||||
characters were written to *str* (excluding the trailing ``'\\0'`` byte at
|
||||
characters were written to *str* (excluding the trailing ``'\0'`` byte at
|
||||
*str*[*rv*]).
|
||||
|
||||
* When ``rv >= size``, the output conversion was truncated and a buffer with
|
||||
``rv + 1`` bytes would have been needed to succeed. *str*[*size*-1] is ``'\\0'``
|
||||
``rv + 1`` bytes would have been needed to succeed. *str*[*size*-1] is ``'\0'``
|
||||
in this case.
|
||||
|
||||
* When ``rv < 0``, "something bad happened." *str*[*size*-1] is ``'\\0'`` in
|
||||
* When ``rv < 0``, "something bad happened." *str*[*size*-1] is ``'\0'`` in
|
||||
this case too, but the rest of *str* is undefined. The exact cause of the error
|
||||
depends on the underlying platform.
|
||||
|
||||
|
@ -100,7 +100,7 @@ setup script). Indirectly provides the :class:`distutils.dist.Distribution` and
|
||||
+--------------------+--------------------------------+-------------------------------------------------------------+
|
||||
|
||||
|
||||
.. function:: run_setup(script_name[, script_args=``None``, stop_after=``'run'``])
|
||||
.. function:: run_setup(script_name[, script_args=None, stop_after='run'])
|
||||
|
||||
Run a setup script in a somewhat controlled environment, and return the
|
||||
:class:`distutils.dist.Distribution` instance that drives things. This is
|
||||
@ -341,7 +341,7 @@ This module provides the following functions.
|
||||
to :command:`build`, :command:`build_ext`, :command:`build_clib`).
|
||||
|
||||
|
||||
.. class:: CCompiler([verbose=``0``, dry_run=``0``, force=``0``])
|
||||
.. class:: CCompiler([verbose=0, dry_run=0, force=0])
|
||||
|
||||
The abstract base class :class:`CCompiler` defines the interface that must be
|
||||
implemented by real compiler classes. The class also has some utility methods
|
||||
@ -431,7 +431,7 @@ This module provides the following functions.
|
||||
runtime linker may search by default.
|
||||
|
||||
|
||||
.. method:: CCompiler.define_macro(name[, value=``None``])
|
||||
.. method:: CCompiler.define_macro(name[, value=None])
|
||||
|
||||
Define a preprocessor macro for all compilations driven by this compiler object.
|
||||
The optional parameter *value* should be a string; if it is not supplied, then
|
||||
@ -442,11 +442,11 @@ This module provides the following functions.
|
||||
.. method:: CCompiler.undefine_macro(name)
|
||||
|
||||
Undefine a preprocessor macro for all compilations driven by this compiler
|
||||
object. If the same macro is defined by :meth:`define_macro` and undefined by
|
||||
:meth:`undefine_macro` the last call takes precedence (including multiple
|
||||
redefinitions or undefinitions). If the macro is redefined/undefined on a per-
|
||||
compilation basis (ie. in the call to :meth:`compile`), then that takes
|
||||
precedence.
|
||||
object. If the same macro is defined by :meth:`define_macro` and
|
||||
undefined by :meth:`undefine_macro` the last call takes precedence
|
||||
(including multiple redefinitions or undefinitions). If the macro is
|
||||
redefined/undefined on a per-compilation basis (ie. in the call to
|
||||
:meth:`compile`), then that takes precedence.
|
||||
|
||||
|
||||
.. method:: CCompiler.add_link_object(object)
|
||||
@ -473,7 +473,7 @@ This module provides the following functions.
|
||||
list) to do the job.
|
||||
|
||||
|
||||
.. method:: CCompiler.find_library_file(dirs, lib[, debug=``0``])
|
||||
.. method:: CCompiler.find_library_file(dirs, lib[, debug=0])
|
||||
|
||||
Search the specified list of directories for a static or shared library file
|
||||
*lib* and return the full path to that file. If *debug* is true, look for a
|
||||
@ -481,7 +481,7 @@ This module provides the following functions.
|
||||
``None`` if *lib* wasn't found in any of the specified directories.
|
||||
|
||||
|
||||
.. method:: CCompiler.has_function(funcname [, includes=``None``, include_dirs=``None``, libraries=``None``, library_dirs=``None``])
|
||||
.. method:: CCompiler.has_function(funcname [, includes=None, include_dirs=None, libraries=None, library_dirs=None])
|
||||
|
||||
Return a boolean indicating whether *funcname* is supported on the current
|
||||
platform. The optional arguments can be used to augment the compilation
|
||||
@ -536,7 +536,7 @@ This module provides the following functions.
|
||||
The following methods invoke stages in the build process.
|
||||
|
||||
|
||||
.. method:: CCompiler.compile(sources[, output_dir=``None``, macros=``None``, include_dirs=``None``, debug=``0``, extra_preargs=``None``, extra_postargs=``None``, depends=``None``])
|
||||
.. method:: CCompiler.compile(sources[, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None])
|
||||
|
||||
Compile one or more source files. Generates object files (e.g. transforms a
|
||||
:file:`.c` file to a :file:`.o` file.)
|
||||
@ -580,7 +580,7 @@ This module provides the following functions.
|
||||
Raises :exc:`CompileError` on failure.
|
||||
|
||||
|
||||
.. method:: CCompiler.create_static_lib(objects, output_libname[, output_dir=``None``, debug=``0``, target_lang=``None``])
|
||||
.. method:: CCompiler.create_static_lib(objects, output_libname[, output_dir=None, debug=0, target_lang=None])
|
||||
|
||||
Link a bunch of stuff together to create a static library file. The "bunch of
|
||||
stuff" consists of the list of object files supplied as *objects*, the extra
|
||||
@ -602,7 +602,7 @@ This module provides the following functions.
|
||||
Raises :exc:`LibError` on failure.
|
||||
|
||||
|
||||
.. method:: CCompiler.link(target_desc, objects, output_filename[, output_dir=``None``, libraries=``None``, library_dirs=``None``, runtime_library_dirs=``None``, export_symbols=``None``, debug=``0``, extra_preargs=``None``, extra_postargs=``None``, build_temp=``None``, target_lang=``None``])
|
||||
.. method:: CCompiler.link(target_desc, objects, output_filename[, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None])
|
||||
|
||||
Link a bunch of stuff together to create an executable or shared library file.
|
||||
|
||||
@ -644,28 +644,28 @@ This module provides the following functions.
|
||||
Raises :exc:`LinkError` on failure.
|
||||
|
||||
|
||||
.. method:: CCompiler.link_executable(objects, output_progname[, output_dir=``None``, libraries=``None``, library_dirs=``None``, runtime_library_dirs=``None``, debug=``0``, extra_preargs=``None``, extra_postargs=``None``, target_lang=``None``])
|
||||
.. method:: CCompiler.link_executable(objects, output_progname[, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, target_lang=None])
|
||||
|
||||
Link an executable. *output_progname* is the name of the file executable, while
|
||||
*objects* are a list of object filenames to link in. Other arguments are as for
|
||||
the :meth:`link` method.
|
||||
|
||||
|
||||
.. method:: CCompiler.link_shared_lib(objects, output_libname[, output_dir=``None``, libraries=``None``, library_dirs=``None``, runtime_library_dirs=``None``, export_symbols=``None``, debug=``0``, extra_preargs=``None``, extra_postargs=``None``, build_temp=``None``, target_lang=``None``])
|
||||
.. method:: CCompiler.link_shared_lib(objects, output_libname[, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None])
|
||||
|
||||
Link a shared library. *output_libname* is the name of the output library,
|
||||
while *objects* is a list of object filenames to link in. Other arguments are
|
||||
as for the :meth:`link` method.
|
||||
|
||||
|
||||
.. method:: CCompiler.link_shared_object(objects, output_filename[, output_dir=``None``, libraries=``None``, library_dirs=``None``, runtime_library_dirs=``None``, export_symbols=``None``, debug=``0``, extra_preargs=``None``, extra_postargs=``None``, build_temp=``None``, target_lang=``None``])
|
||||
.. method:: CCompiler.link_shared_object(objects, output_filename[, output_dir=None, libraries=None, library_dirs=None, runtime_library_dirs=None, export_symbols=None, debug=0, extra_preargs=None, extra_postargs=None, build_temp=None, target_lang=None])
|
||||
|
||||
Link a shared object. *output_filename* is the name of the shared object that
|
||||
will be created, while *objects* is a list of object filenames to link in.
|
||||
Other arguments are as for the :meth:`link` method.
|
||||
|
||||
|
||||
.. method:: CCompiler.preprocess(source[, output_file=``None``, macros=``None``, include_dirs=``None``, extra_preargs=``None``, extra_postargs=``None``])
|
||||
.. method:: CCompiler.preprocess(source[, output_file=None, macros=None, include_dirs=None, extra_preargs=None, extra_postargs=None])
|
||||
|
||||
Preprocess a single C/C++ source file, named in *source*. Output will be written
|
||||
to file named *output_file*, or *stdout* if *output_file* not supplied.
|
||||
@ -680,14 +680,14 @@ This module provides the following functions.
|
||||
use by the various concrete subclasses.
|
||||
|
||||
|
||||
.. method:: CCompiler.executable_filename(basename[, strip_dir=``0``, output_dir=``''``])
|
||||
.. method:: CCompiler.executable_filename(basename[, strip_dir=0, output_dir=''])
|
||||
|
||||
Returns the filename of the executable for the given *basename*. Typically for
|
||||
non-Windows platforms this is the same as the basename, while Windows will get
|
||||
a :file:`.exe` added.
|
||||
|
||||
|
||||
.. method:: CCompiler.library_filename(libname[, lib_type=``'static'``, strip_dir=``0``, output_dir=``''``])
|
||||
.. method:: CCompiler.library_filename(libname[, lib_type='static', strip_dir=0, output_dir=''])
|
||||
|
||||
Returns the filename for the given library name on the current platform. On Unix
|
||||
a library with *lib_type* of ``'static'`` will typically be of the form
|
||||
@ -695,18 +695,18 @@ This module provides the following functions.
|
||||
:file:`liblibname.so`.
|
||||
|
||||
|
||||
.. method:: CCompiler.object_filenames(source_filenames[, strip_dir=``0``, output_dir=``''``])
|
||||
.. method:: CCompiler.object_filenames(source_filenames[, strip_dir=0, output_dir=''])
|
||||
|
||||
Returns the name of the object files for the given source files.
|
||||
*source_filenames* should be a list of filenames.
|
||||
|
||||
|
||||
.. method:: CCompiler.shared_object_filename(basename[, strip_dir=``0``, output_dir=``''``])
|
||||
.. method:: CCompiler.shared_object_filename(basename[, strip_dir=0, output_dir=''])
|
||||
|
||||
Returns the name of a shared object file for the given file name *basename*.
|
||||
|
||||
|
||||
.. method:: CCompiler.execute(func, args[, msg=``None``, level=``1``])
|
||||
.. method:: CCompiler.execute(func, args[, msg=None, level=1])
|
||||
|
||||
Invokes :func:`distutils.util.execute` This method invokes a Python function
|
||||
*func* with the given arguments *args*, after logging and taking into account
|
||||
@ -719,7 +719,7 @@ This module provides the following functions.
|
||||
the given command. XXX see also.
|
||||
|
||||
|
||||
.. method:: CCompiler.mkpath(name[, mode=``511``])
|
||||
.. method:: CCompiler.mkpath(name[, mode=511])
|
||||
|
||||
Invokes :func:`distutils.dir_util.mkpath`. This creates a directory and any
|
||||
missing ancestor directories. XXX see also.
|
||||
@ -731,7 +731,7 @@ This module provides the following functions.
|
||||
also.
|
||||
|
||||
|
||||
.. method:: CCompiler.announce(msg[, level=``1``])
|
||||
.. method:: CCompiler.announce(msg[, level=1])
|
||||
|
||||
Write a message using :func:`distutils.log.debug`. XXX see also.
|
||||
|
||||
@ -867,7 +867,7 @@ This module provides a few functions for creating archive files, such as
|
||||
tarballs or zipfiles.
|
||||
|
||||
|
||||
.. function:: make_archive(base_name, format[, root_dir=``None``, base_dir=``None``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: make_archive(base_name, format[, root_dir=None, base_dir=None, verbose=0, dry_run=0])
|
||||
|
||||
Create an archive file (eg. ``zip`` or ``tar``). *base_name* is the name of
|
||||
the file to create, minus any format-specific extension; *format* is the
|
||||
@ -883,7 +883,7 @@ tarballs or zipfiles.
|
||||
This should be changed to support bz2 files
|
||||
|
||||
|
||||
.. function:: make_tarball(base_name, base_dir[, compress=``'gzip'``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: make_tarball(base_name, base_dir[, compress='gzip', verbose=0, dry_run=0])
|
||||
|
||||
'Create an (optional compressed) archive as a tar file from all files in and
|
||||
under *base_dir*. *compress* must be ``'gzip'`` (the default), ``'compress'``,
|
||||
@ -898,7 +898,7 @@ tarballs or zipfiles.
|
||||
This should be replaced with calls to the :mod:`tarfile` module.
|
||||
|
||||
|
||||
.. function:: make_zipfile(base_name, base_dir[, verbose=``0``, dry_run=``0``])
|
||||
.. function:: make_zipfile(base_name, base_dir[, verbose=0, dry_run=0])
|
||||
|
||||
Create a zip file from all files in and under *base_dir*. The output zip file
|
||||
will be named *base_dir* + :file:`.zip`. Uses either the :mod:`zipfile` Python
|
||||
@ -936,7 +936,7 @@ timestamp dependency analysis.
|
||||
.. % % equivalent to a listcomp...
|
||||
|
||||
|
||||
.. function:: newer_group(sources, target[, missing=``'error'``])
|
||||
.. function:: newer_group(sources, target[, missing='error'])
|
||||
|
||||
Return true if *target* is out-of-date with respect to any file listed in
|
||||
*sources* In other words, if *target* exists and is newer than every file in
|
||||
@ -961,7 +961,7 @@ This module provides functions for operating on directories and trees of
|
||||
directories.
|
||||
|
||||
|
||||
.. function:: mkpath(name[, mode=``0777``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: mkpath(name[, mode=0777, verbose=0, dry_run=0])
|
||||
|
||||
Create a directory and any missing ancestor directories. If the directory
|
||||
already exists (or if *name* is the empty string, which means the current
|
||||
@ -972,7 +972,7 @@ directories.
|
||||
directories actually created.
|
||||
|
||||
|
||||
.. function:: create_tree(base_dir, files[, mode=``0777``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: create_tree(base_dir, files[, mode=0777, verbose=0, dry_run=0])
|
||||
|
||||
Create all the empty directories under *base_dir* needed to put *files* there.
|
||||
*base_dir* is just the a name of a directory which doesn't necessarily exist
|
||||
@ -982,7 +982,7 @@ directories.
|
||||
:func:`mkpath`.
|
||||
|
||||
|
||||
.. function:: copy_tree(src, dst[preserve_mode=``1``, preserve_times=``1``, preserve_symlinks=``0``, update=``0``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: copy_tree(src, dst[, preserve_mode=1, preserve_times=1, preserve_symlinks=0, update=0, verbose=0, dry_run=0])
|
||||
|
||||
Copy an entire directory tree *src* to a new location *dst*. Both *src* and
|
||||
*dst* must be directory names. If *src* is not a directory, raise
|
||||
@ -1002,7 +1002,7 @@ directories.
|
||||
as for :func:`copy_file`.
|
||||
|
||||
|
||||
.. function:: remove_tree(directory[verbose=``0``, dry_run=``0``])
|
||||
.. function:: remove_tree(directory[, verbose=0, dry_run=0])
|
||||
|
||||
Recursively remove *directory* and all files and directories underneath it. Any
|
||||
errors are ignored (apart from being reported to ``sys.stdout`` if *verbose* is
|
||||
@ -1021,16 +1021,16 @@ directories.
|
||||
This module contains some utility functions for operating on individual files.
|
||||
|
||||
|
||||
.. function:: copy_file(src, dst[preserve_mode=``1``, preserve_times=``1``, update=``0``, link=``None``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: copy_file(src, dst[, preserve_mode=1, preserve_times=1, update=0, link=None, verbose=0, dry_run=0])
|
||||
|
||||
Copy file *src* to *dst*. If *dst* is a directory, then *src* is copied there
|
||||
with the same name; otherwise, it must be a filename. (If the file exists, it
|
||||
will be ruthlessly clobbered.) If *preserve_mode* is true (the default), the
|
||||
file's mode (type and permission bits, or whatever is analogous on the current
|
||||
platform) is copied. If *preserve_times* is true (the default), the last-
|
||||
modified and last-access times are copied as well. If *update* is true, *src*
|
||||
will only be copied if *dst* does not exist, or if *dst* does exist but is older
|
||||
than *src*.
|
||||
file's mode (type and permission bits, or whatever is analogous on the
|
||||
current platform) is copied. If *preserve_times* is true (the default), the
|
||||
last-modified and last-access times are copied as well. If *update* is true,
|
||||
*src* will only be copied if *dst* does not exist, or if *dst* does exist but
|
||||
is older than *src*.
|
||||
|
||||
*link* allows you to make hard links (using :func:`os.link`) or symbolic links
|
||||
(using :func:`os.symlink`) instead of copying: set it to ``'hard'`` or
|
||||
@ -1051,7 +1051,7 @@ This module contains some utility functions for operating on individual files.
|
||||
.. % (not update) and (src newer than dst)).
|
||||
|
||||
|
||||
.. function:: move_file(src, dst[verbose, dry_run])
|
||||
.. function:: move_file(src, dst[, verbose, dry_run])
|
||||
|
||||
Move file *src* to *dst*. If *dst* is a directory, the file will be moved into
|
||||
it with the same name; otherwise, *src* is just renamed to *dst*. Returns the
|
||||
@ -1092,15 +1092,11 @@ other utility module.
|
||||
|
||||
Examples of returned values:
|
||||
|
||||
* ``linux-i586``
|
||||
|
||||
* ``linux-alpha``
|
||||
|
||||
* ``solaris-2.6-sun4u``
|
||||
|
||||
* ``irix-5.3``
|
||||
|
||||
* ``irix64-6.2``
|
||||
* ``linux-i586``
|
||||
* ``linux-alpha``
|
||||
* ``solaris-2.6-sun4u``
|
||||
* ``irix-5.3``
|
||||
* ``irix64-6.2``
|
||||
|
||||
For non-POSIX platforms, currently just returns ``sys.platform``.
|
||||
|
||||
@ -1130,9 +1126,8 @@ other utility module.
|
||||
users can use in config files, command-line options, etc. Currently this
|
||||
includes:
|
||||
|
||||
* :envvar:`HOME` - user's home directory (Unix only)
|
||||
|
||||
* :envvar:`PLAT` - description of the current platform, including hardware and
|
||||
* :envvar:`HOME` - user's home directory (Unix only)
|
||||
* :envvar:`PLAT` - description of the current platform, including hardware and
|
||||
OS (see :func:`get_platform`)
|
||||
|
||||
|
||||
@ -1150,7 +1145,7 @@ other utility module.
|
||||
underscore. No { } or ( ) style quoting is available.
|
||||
|
||||
|
||||
.. function:: grok_environment_error(exc[, prefix=``'error: '``])
|
||||
.. function:: grok_environment_error(exc[, prefix='error: '])
|
||||
|
||||
Generate a useful error message from an :exc:`EnvironmentError` (:exc:`IOError`
|
||||
or :exc:`OSError`) exception object. Handles Python 1.5.1 and later styles,
|
||||
@ -1173,7 +1168,7 @@ other utility module.
|
||||
.. % Should probably be moved into the standard library.
|
||||
|
||||
|
||||
.. function:: execute(func, args[, msg=``None``, verbose=``0``, dry_run=``0``])
|
||||
.. function:: execute(func, args[, msg=None, verbose=0, dry_run=0])
|
||||
|
||||
Perform some action that affects the outside world (for instance, writing to the
|
||||
filesystem). Such actions are special because they are disabled by the
|
||||
@ -1191,18 +1186,16 @@ other utility module.
|
||||
:exc:`ValueError` if *val* is anything else.
|
||||
|
||||
|
||||
.. function:: byte_compile(py_files[, optimize=``0``, force=``0``, prefix=``None``, base_dir=``None``, verbose=``1``, dry_run=``0``, direct=``None``])
|
||||
.. function:: byte_compile(py_files[, optimize=0, force=0, prefix=None, base_dir=None, verbose=1, dry_run=0, direct=None])
|
||||
|
||||
Byte-compile a collection of Python source files to either :file:`.pyc` or
|
||||
:file:`.pyo` files in the same directory. *py_files* is a list of files to
|
||||
compile; any files that don't end in :file:`.py` are silently skipped.
|
||||
*optimize* must be one of the following:
|
||||
|
||||
* ``0`` - don't optimize (generate :file:`.pyc`)
|
||||
|
||||
* ``1`` - normal optimization (like ``python -O``)
|
||||
|
||||
* ``2`` - extra optimization (like ``python -OO``)
|
||||
* ``0`` - don't optimize (generate :file:`.pyc`)
|
||||
* ``1`` - normal optimization (like ``python -O``)
|
||||
* ``2`` - extra optimization (like ``python -OO``)
|
||||
|
||||
If *force* is true, all files are recompiled regardless of timestamps.
|
||||
|
||||
@ -1333,7 +1326,7 @@ provides the following additional features:
|
||||
later).
|
||||
|
||||
|
||||
.. class:: FancyGetopt([option_table=``None``])
|
||||
.. class:: FancyGetopt([option_table=None])
|
||||
|
||||
The option_table is a list of 3-tuples: ``(long_option, short_option,
|
||||
help_string)``
|
||||
@ -1346,7 +1339,7 @@ provides the following additional features:
|
||||
The :class:`FancyGetopt` class provides the following methods:
|
||||
|
||||
|
||||
.. method:: FancyGetopt.getopt([args=``None``, object=``None``])
|
||||
.. method:: FancyGetopt.getopt([args=None, object=None])
|
||||
|
||||
Parse command-line options in args. Store as attributes on *object*.
|
||||
|
||||
@ -1367,7 +1360,7 @@ The :class:`FancyGetopt` class provides the following methods:
|
||||
yet.
|
||||
|
||||
|
||||
.. method:: FancyGetopt.generate_help([header=``None``])
|
||||
.. method:: FancyGetopt.generate_help([header=None])
|
||||
|
||||
Generate help text (a list of strings, one per suggested line of output) from
|
||||
the option table for this :class:`FancyGetopt` object.
|
||||
@ -1540,7 +1533,7 @@ text files that (optionally) takes care of stripping comments, ignoring blank
|
||||
lines, and joining lines with backslashes.
|
||||
|
||||
|
||||
.. class:: TextFile([filename=``None``, file=``None``, **options])
|
||||
.. class:: TextFile([filename=None, file=None, **options])
|
||||
|
||||
This class provides a file-like object that takes care of all the things you
|
||||
commonly want to do when processing a text file that has some line-by-line
|
||||
@ -1628,7 +1621,7 @@ lines, and joining lines with backslashes.
|
||||
filename and the current line number).
|
||||
|
||||
|
||||
.. method:: TextFile.warn(msg[,line=``None``])
|
||||
.. method:: TextFile.warn(msg[,line=None])
|
||||
|
||||
Print (to stderr) a warning message tied to the current logical line in the
|
||||
current file. If the current logical line in the file spans multiple physical
|
||||
@ -1952,12 +1945,12 @@ Subclasses of :class:`Command` must define the following methods.
|
||||
|
||||
.. method:: Command.finalize_options()
|
||||
|
||||
Set final values for all the options that this command supports. This is always
|
||||
called as late as possible, ie. after any option assignments from the command-
|
||||
line or from other commands have been done. Thus, this is the place to to code
|
||||
option dependencies: if *foo* depends on *bar*, then it is safe to set *foo*
|
||||
from *bar* as long as *foo* still has the same value it was assigned in
|
||||
:meth:`initialize_options`.
|
||||
Set final values for all the options that this command supports. This is
|
||||
always called as late as possible, ie. after any option assignments from the
|
||||
command-line or from other commands have been done. Thus, this is the place
|
||||
to to code option dependencies: if *foo* depends on *bar*, then it is safe to
|
||||
set *foo* from *bar* as long as *foo* still has the same value it was
|
||||
assigned in :meth:`initialize_options`.
|
||||
|
||||
|
||||
.. method:: Command.run()
|
||||
|
@ -47,14 +47,13 @@ up in a subdirectory :file:`build/lib.system`, and may have a name like
|
||||
:file:`demo.so` or :file:`demo.pyd`.
|
||||
|
||||
In the :file:`setup.py`, all execution is performed by calling the ``setup``
|
||||
function. This takes a variable number of keyword arguments, of which the
|
||||
example above uses only a subset. Specifically, the example specifies meta-
|
||||
information to build packages, and it specifies the contents of the package.
|
||||
Normally, a package will contain of addition modules, like Python source
|
||||
modules, documentation, subpackages, etc. Please refer to the distutils
|
||||
documentation in :ref:`distutils-index`
|
||||
to learn more about the features of distutils; this section explains building
|
||||
extension modules only.
|
||||
function. This takes a variable number of keyword arguments, of which the
|
||||
example above uses only a subset. Specifically, the example specifies
|
||||
meta-information to build packages, and it specifies the contents of the
|
||||
package. Normally, a package will contain of addition modules, like Python
|
||||
source modules, documentation, subpackages, etc. Please refer to the distutils
|
||||
documentation in :ref:`distutils-index` to learn more about the features of
|
||||
distutils; this section explains building extension modules only.
|
||||
|
||||
It is common to pre-compute arguments to :func:`setup`, to better structure the
|
||||
driver script. In the example above, the\ ``ext_modules`` argument to
|
||||
|
@ -165,9 +165,9 @@ error on to the interpreter but wants to handle it completely by itself
|
||||
|
||||
Every failing :cfunc:`malloc` call must be turned into an exception --- the
|
||||
direct caller of :cfunc:`malloc` (or :cfunc:`realloc`) must call
|
||||
:cfunc:`PyErr_NoMemory` and return a failure indicator itself. All the object-
|
||||
creating functions (for example, :cfunc:`PyInt_FromLong`) already do this, so
|
||||
this note is only relevant to those who call :cfunc:`malloc` directly.
|
||||
:cfunc:`PyErr_NoMemory` and return a failure indicator itself. All the
|
||||
object-creating functions (for example, :cfunc:`PyInt_FromLong`) already do
|
||||
this, so this note is only relevant to those who call :cfunc:`malloc` directly.
|
||||
|
||||
Also note that, with the important exception of :cfunc:`PyArg_ParseTuple` and
|
||||
friends, functions that return an integer status usually return a positive value
|
||||
@ -332,9 +332,9 @@ satisfactorily.
|
||||
|
||||
When embedding Python, the :cfunc:`initspam` function is not called
|
||||
automatically unless there's an entry in the :cdata:`_PyImport_Inittab` table.
|
||||
The easiest way to handle this is to statically initialize your statically-
|
||||
linked modules by directly calling :cfunc:`initspam` after the call to
|
||||
:cfunc:`Py_Initialize`::
|
||||
The easiest way to handle this is to statically initialize your
|
||||
statically-linked modules by directly calling :cfunc:`initspam` after the call
|
||||
to :cfunc:`Py_Initialize`::
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
@ -488,10 +488,10 @@ between parentheses. For example::
|
||||
Py_DECREF(arglist);
|
||||
|
||||
:cfunc:`PyEval_CallObject` returns a Python object pointer: this is the return
|
||||
value of the Python function. :cfunc:`PyEval_CallObject` is "reference-count-
|
||||
neutral" with respect to its arguments. In the example a new tuple was created
|
||||
to serve as the argument list, which is :cfunc:`Py_DECREF`\ -ed immediately
|
||||
after the call.
|
||||
value of the Python function. :cfunc:`PyEval_CallObject` is
|
||||
"reference-count-neutral" with respect to its arguments. In the example a new
|
||||
tuple was created to serve as the argument list, which is :cfunc:`Py_DECREF`\
|
||||
-ed immediately after the call.
|
||||
|
||||
The return value of :cfunc:`PyEval_CallObject` is "new": either it is a brand
|
||||
new object, or it is an existing object whose reference count has been
|
||||
|
@ -700,10 +700,10 @@ means that :class:`Noddy` objects can participate in cycles::
|
||||
>>> l = [n]
|
||||
>>> n.first = l
|
||||
|
||||
This is pretty silly, but it gives us an excuse to add support for the cyclic-
|
||||
garbage collector to the :class:`Noddy` example. To support cyclic garbage
|
||||
collection, types need to fill two slots and set a class flag that enables these
|
||||
slots:
|
||||
This is pretty silly, but it gives us an excuse to add support for the
|
||||
cyclic-garbage collector to the :class:`Noddy` example. To support cyclic
|
||||
garbage collection, types need to fill two slots and set a class flag that
|
||||
enables these slots:
|
||||
|
||||
.. literalinclude:: ../includes/noddy4.c
|
||||
|
||||
|
@ -232,9 +232,9 @@ The Internet community surrounding the language is an active one, and is worth
|
||||
being considered another one of Python's advantages. Most questions posted to
|
||||
the comp.lang.python newsgroup are quickly answered by someone.
|
||||
|
||||
Should you need to dig into the source code, you'll find it's clear and well-
|
||||
organized, so it's not very difficult to write extensions and track down bugs
|
||||
yourself. If you'd prefer to pay for support, there are companies and
|
||||
Should you need to dig into the source code, you'll find it's clear and
|
||||
well-organized, so it's not very difficult to write extensions and track down
|
||||
bugs yourself. If you'd prefer to pay for support, there are companies and
|
||||
individuals who offer commercial support for Python.
|
||||
|
||||
**Who uses Python for serious work?**
|
||||
|
@ -15,36 +15,37 @@
|
||||
What is curses?
|
||||
===============
|
||||
|
||||
The curses library supplies a terminal-independent screen-painting and keyboard-
|
||||
handling facility for text-based terminals; such terminals include VT100s, the
|
||||
Linux console, and the simulated terminal provided by X11 programs such as xterm
|
||||
and rxvt. Display terminals support various control codes to perform common
|
||||
operations such as moving the cursor, scrolling the screen, and erasing areas.
|
||||
Different terminals use widely differing codes, and often have their own minor
|
||||
quirks.
|
||||
The curses library supplies a terminal-independent screen-painting and
|
||||
keyboard-handling facility for text-based terminals; such terminals include
|
||||
VT100s, the Linux console, and the simulated terminal provided by X11 programs
|
||||
such as xterm and rxvt. Display terminals support various control codes to
|
||||
perform common operations such as moving the cursor, scrolling the screen, and
|
||||
erasing areas. Different terminals use widely differing codes, and often have
|
||||
their own minor quirks.
|
||||
|
||||
In a world of X displays, one might ask "why bother"? It's true that character-
|
||||
cell display terminals are an obsolete technology, but there are niches in which
|
||||
being able to do fancy things with them are still valuable. One is on small-
|
||||
footprint or embedded Unixes that don't carry an X server. Another is for
|
||||
tools like OS installers and kernel configurators that may have to run before X
|
||||
is available.
|
||||
In a world of X displays, one might ask "why bother"? It's true that
|
||||
character-cell display terminals are an obsolete technology, but there are
|
||||
niches in which being able to do fancy things with them are still valuable. One
|
||||
is on small-footprint or embedded Unixes that don't carry an X server. Another
|
||||
is for tools like OS installers and kernel configurators that may have to run
|
||||
before X is available.
|
||||
|
||||
The curses library hides all the details of different terminals, and provides
|
||||
the programmer with an abstraction of a display, containing multiple non-
|
||||
overlapping windows. The contents of a window can be changed in various ways--
|
||||
adding text, erasing it, changing its appearance--and the curses library will
|
||||
automagically figure out what control codes need to be sent to the terminal to
|
||||
produce the right output.
|
||||
the programmer with an abstraction of a display, containing multiple
|
||||
non-overlapping windows. The contents of a window can be changed in various
|
||||
ways-- adding text, erasing it, changing its appearance--and the curses library
|
||||
will automagically figure out what control codes need to be sent to the terminal
|
||||
to produce the right output.
|
||||
|
||||
The curses library was originally written for BSD Unix; the later System V
|
||||
versions of Unix from AT&T added many enhancements and new functions. BSD curses
|
||||
is no longer maintained, having been replaced by ncurses, which is an open-
|
||||
source implementation of the AT&T interface. If you're using an open-source
|
||||
Unix such as Linux or FreeBSD, your system almost certainly uses ncurses. Since
|
||||
most current commercial Unix versions are based on System V code, all the
|
||||
functions described here will probably be available. The older versions of
|
||||
curses carried by some proprietary Unixes may not support everything, though.
|
||||
is no longer maintained, having been replaced by ncurses, which is an
|
||||
open-source implementation of the AT&T interface. If you're using an
|
||||
open-source Unix such as Linux or FreeBSD, your system almost certainly uses
|
||||
ncurses. Since most current commercial Unix versions are based on System V
|
||||
code, all the functions described here will probably be available. The older
|
||||
versions of curses carried by some proprietary Unixes may not support
|
||||
everything, though.
|
||||
|
||||
No one has made a Windows port of the curses module. On a Windows platform, try
|
||||
the Console module written by Fredrik Lundh. The Console module provides
|
||||
|
@ -272,8 +272,8 @@ classical use of :func:`reduce` is something like ::
|
||||
print reduce(operator.add, nums)/len(nums)
|
||||
|
||||
This cute little script prints the average of all numbers given on the command
|
||||
line. The :func:`reduce` adds up all the numbers, and the rest is just some pre-
|
||||
and postprocessing.
|
||||
line. The :func:`reduce` adds up all the numbers, and the rest is just some
|
||||
pre- and postprocessing.
|
||||
|
||||
On the same note, note that :func:`float`, :func:`int` and :func:`long` all
|
||||
accept arguments of type string, and so are suited to parsing --- assuming you
|
||||
|
@ -1035,7 +1035,7 @@ returns true, and then returns the rest of the iterable's results.
|
||||
|
||||
|
||||
Grouping elements
|
||||
'''''''''''''''''
|
||||
-----------------
|
||||
|
||||
The last function I'll discuss, ``itertools.groupby(iter, key_func=None)``, is
|
||||
the most complicated. ``key_func(elem)`` is a function that can compute a key
|
||||
|
@ -367,9 +367,9 @@ module. If you have Tkinter available, you may also want to look at
|
||||
:file:`Tools/scripts/redemo.py`, a demonstration program included with the
|
||||
Python distribution. It allows you to enter REs and strings, and displays
|
||||
whether the RE matches or fails. :file:`redemo.py` can be quite useful when
|
||||
trying to debug a complicated RE. Phil Schwartz's `Kodos <http://www.phil-
|
||||
schwartz.com/kodos.spy>`_ is also an interactive tool for developing and testing
|
||||
RE patterns.
|
||||
trying to debug a complicated RE. Phil Schwartz's `Kodos
|
||||
<http://www.phil-schwartz.com/kodos.spy>`_ is also an interactive tool for
|
||||
developing and testing RE patterns.
|
||||
|
||||
This HOWTO uses the standard Python interpreter for its examples. First, run the
|
||||
Python interpreter, import the :mod:`re` module, and compile a RE::
|
||||
@ -708,10 +708,10 @@ given location, they can obviously be matched an infinite number of times.
|
||||
Matches only at the end of the string.
|
||||
|
||||
``\b``
|
||||
Word boundary. This is a zero-width assertion that matches only at the
|
||||
Word boundary. This is a zero-width assertion that matches only at the
|
||||
beginning or end of a word. A word is defined as a sequence of alphanumeric
|
||||
characters, so the end of a word is indicated by whitespace or a non-
|
||||
alphanumeric character.
|
||||
characters, so the end of a word is indicated by whitespace or a
|
||||
non-alphanumeric character.
|
||||
|
||||
The following example matches ``class`` only when it's a complete word; it won't
|
||||
match when it's contained inside another word. ::
|
||||
@ -1057,7 +1057,7 @@ whitespace or by a fixed string. As you'd expect, there's a module-level
|
||||
:func:`re.split` function, too.
|
||||
|
||||
|
||||
.. method:: .split(string [, maxsplit\ ``= 0``])
|
||||
.. method:: .split(string [, maxsplit=0])
|
||||
:noindex:
|
||||
|
||||
Split *string* by the matches of the regular expression. If capturing
|
||||
@ -1108,7 +1108,7 @@ with a different string. The :meth:`sub` method takes a replacement value,
|
||||
which can be either a string or a function, and the string to be processed.
|
||||
|
||||
|
||||
.. method:: .sub(replacement, string[, count\ ``= 0``])
|
||||
.. method:: .sub(replacement, string[, count=0])
|
||||
:noindex:
|
||||
|
||||
Returns the string obtained by replacing the leftmost non-overlapping
|
||||
@ -1307,11 +1307,11 @@ at every step. This produces just the right result::
|
||||
>>> print re.match('<.*?>', s).group()
|
||||
<html>
|
||||
|
||||
(Note that parsing HTML or XML with regular expressions is painful. Quick-and-
|
||||
dirty patterns will handle common cases, but HTML and XML have special cases
|
||||
that will break the obvious regular expression; by the time you've written a
|
||||
regular expression that handles all of the possible cases, the patterns will be
|
||||
*very* complicated. Use an HTML or XML parser module for such tasks.)
|
||||
(Note that parsing HTML or XML with regular expressions is painful.
|
||||
Quick-and-dirty patterns will handle common cases, but HTML and XML have special
|
||||
cases that will break the obvious regular expression; by the time you've written
|
||||
a regular expression that handles all of the possible cases, the patterns will
|
||||
be *very* complicated. Use an HTML or XML parser module for such tasks.)
|
||||
|
||||
|
||||
Not Using re.VERBOSE
|
||||
@ -1366,9 +1366,9 @@ The most complete book on regular expressions is almost certainly Jeffrey
|
||||
Friedl's Mastering Regular Expressions, published by O'Reilly. Unfortunately,
|
||||
it exclusively concentrates on Perl and Java's flavours of regular expressions,
|
||||
and doesn't contain any Python material at all, so it won't be useful as a
|
||||
reference for programming in Python. (The first edition covered Python's now-
|
||||
removed :mod:`regex` module, which won't help you much.) Consider checking it
|
||||
out from your library.
|
||||
reference for programming in Python. (The first edition covered Python's
|
||||
now-removed :mod:`regex` module, which won't help you much.) Consider checking
|
||||
it out from your library.
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
@ -29,8 +29,8 @@ know what you're doing (in which case this HOWTO isn't for you!), you'll get
|
||||
better behavior and performance from a STREAM socket than anything else. I will
|
||||
try to clear up the mystery of what a socket is, as well as some hints on how to
|
||||
work with blocking and non-blocking sockets. But I'll start by talking about
|
||||
blocking sockets. You'll need to know how they work before dealing with non-
|
||||
blocking sockets.
|
||||
blocking sockets. You'll need to know how they work before dealing with
|
||||
non-blocking sockets.
|
||||
|
||||
Part of the trouble with understanding these things is that "socket" can mean a
|
||||
number of subtly different things, depending on context. So first, let's make a
|
||||
@ -361,12 +361,12 @@ readable, writable and in error. Each of these lists is a subset (possbily
|
||||
empty) of the corresponding list you passed in. And if you put a socket in more
|
||||
than one input list, it will only be (at most) in one output list.
|
||||
|
||||
If a socket is in the output readable list, you can be as-close-to-certain-as-
|
||||
we-ever-get-in-this-business that a ``recv`` on that socket will return
|
||||
*something*. Same idea for the writable list. You'll be able to send
|
||||
*something*. Maybe not all you want to, but *something* is better than nothing.
|
||||
(Actually, any reasonably healthy socket will return as writable - it just means
|
||||
outbound network buffer space is available.)
|
||||
If a socket is in the output readable list, you can be
|
||||
as-close-to-certain-as-we-ever-get-in-this-business that a ``recv`` on that
|
||||
socket will return *something*. Same idea for the writable list. You'll be able
|
||||
to send *something*. Maybe not all you want to, but *something* is better than
|
||||
nothing. (Actually, any reasonably healthy socket will return as writable - it
|
||||
just means outbound network buffer space is available.)
|
||||
|
||||
If you have a "server" socket, put it in the potential_readers list. If it comes
|
||||
out in the readable list, your ``accept`` will (almost certainly) work. If you
|
||||
|
@ -432,7 +432,7 @@ Basic Authentication
|
||||
====================
|
||||
|
||||
To illustrate creating and installing a handler we will use the
|
||||
``HTTPBasicAuthHandler``. For a more detailed discussion of this subject -
|
||||
``HTTPBasicAuthHandler``. For a more detailed discussion of this subject --
|
||||
including an explanation of how Basic Authentication works - see the `Basic
|
||||
Authentication Tutorial
|
||||
<http://www.voidspace.org.uk/python/articles/authentication.shtml>`_.
|
||||
|
@ -263,7 +263,7 @@ the same under Windows, and very often the same under Unix and Mac OS X. You
|
||||
can find out what your Python installation uses for :file:`{prefix}` and
|
||||
:file:`{exec-prefix}` by running Python in interactive mode and typing a few
|
||||
simple commands. Under Unix, just type ``python`` at the shell prompt. Under
|
||||
Windows, choose :menuselection:`Start --> Programs --> Python |version|-->
|
||||
Windows, choose :menuselection:`Start --> Programs --> Python X.Y -->
|
||||
Python (command line)`. Once the interpreter is started, you type Python code
|
||||
at the prompt. For example, on my Linux system, I type the three Python
|
||||
statements shown below, and get the output as shown, to find out my
|
||||
@ -506,8 +506,8 @@ section :ref:`inst-search-path` to find out how to modify Python's search path.
|
||||
|
||||
If you want to define an entire installation scheme, you just have to supply all
|
||||
of the installation directory options. The recommended way to do this is to
|
||||
supply relative paths; for example, if you want to maintain all Python module-
|
||||
related files under :file:`python` in your home directory, and you want a
|
||||
supply relative paths; for example, if you want to maintain all Python
|
||||
module-related files under :file:`python` in your home directory, and you want a
|
||||
separate directory for each platform that you use your home directory from, you
|
||||
might define the following installation scheme::
|
||||
|
||||
@ -645,8 +645,8 @@ before doing the installation.
|
||||
There are two environment variables that can modify ``sys.path``.
|
||||
:envvar:`PYTHONHOME` sets an alternate value for the prefix of the Python
|
||||
installation. For example, if :envvar:`PYTHONHOME` is set to ``/www/python``,
|
||||
the search path will be set to ``['', '/www/python/lib/python|version|/',
|
||||
'/www/python/lib/python|version|/plat-linux2', ...]``.
|
||||
the search path will be set to ``['', '/www/python/lib/pythonX.Y/',
|
||||
'/www/python/lib/pythonX.Y/plat-linux2', ...]``.
|
||||
|
||||
The :envvar:`PYTHONPATH` variable can be set to a list of paths that will be
|
||||
added to the beginning of ``sys.path``. For example, if :envvar:`PYTHONPATH` is
|
||||
@ -812,8 +812,8 @@ Tweaking compiler/linker flags
|
||||
Compiling a Python extension written in C or C++ will sometimes require
|
||||
specifying custom flags for the compiler and linker in order to use a particular
|
||||
library or produce a special kind of object code. This is especially true if the
|
||||
extension hasn't been tested on your platform, or if you're trying to cross-
|
||||
compile Python.
|
||||
extension hasn't been tested on your platform, or if you're trying to
|
||||
cross-compile Python.
|
||||
|
||||
In the most general case, the extension author might have foreseen that
|
||||
compiling the extensions would be complicated, and provided a :file:`Setup` file
|
||||
|
@ -178,7 +178,7 @@ This module offers the following functions:
|
||||
:const:`HKEY_LOCAL_MACHINE` tree. This may or may not be true.
|
||||
|
||||
|
||||
.. function:: OpenKey(key, sub_key[, res\ ``= 0``][, sam\ ``= KEY_READ``])
|
||||
.. function:: OpenKey(key, sub_key[, res=0][, sam=KEY_READ])
|
||||
|
||||
Opens the specified key, returning a :dfn:`handle object`
|
||||
|
||||
|
@ -23,15 +23,15 @@ bound. If your program is processor bound, then pre-emptive scheduled threads
|
||||
are probably what you really need. Network servers are rarely processor bound,
|
||||
however.
|
||||
|
||||
If your operating system supports the :cfunc:`select` system call in its I/O
|
||||
library (and nearly all do), then you can use it to juggle multiple
|
||||
communication channels at once; doing other work while your I/O is taking place
|
||||
in the "background." Although this strategy can seem strange and complex,
|
||||
especially at first, it is in many ways easier to understand and control than
|
||||
multi-threaded programming. The :mod:`asyncore` module solves many of the
|
||||
difficult problems for you, making the task of building sophisticated high-
|
||||
performance network servers and clients a snap. For "conversational"
|
||||
applications and protocols the companion :mod:`asynchat` module is invaluable.
|
||||
If your operating system supports the :cfunc:`select` system call in its I/O
|
||||
library (and nearly all do), then you can use it to juggle multiple
|
||||
communication channels at once; doing other work while your I/O is taking place
|
||||
in the "background." Although this strategy can seem strange and complex,
|
||||
especially at first, it is in many ways easier to understand and control than
|
||||
multi-threaded programming. The :mod:`asyncore` module solves many of the
|
||||
difficult problems for you, making the task of building sophisticated
|
||||
high-performance network servers and clients a snap. For "conversational"
|
||||
applications and protocols the companion :mod:`asynchat` module is invaluable.
|
||||
|
||||
The basic idea behind both modules is to create one or more network *channels*,
|
||||
instances of class :class:`asyncore.dispatcher` and
|
||||
|
@ -16,8 +16,8 @@ The :mod:`binascii` module contains a number of methods to convert between
|
||||
binary and various ASCII-encoded binary representations. Normally, you will not
|
||||
use these functions directly but use wrapper modules like :mod:`uu`,
|
||||
:mod:`base64`, or :mod:`binhex` instead. The :mod:`binascii` module contains
|
||||
low-level functions written in C for greater speed that are used by the higher-
|
||||
level modules.
|
||||
low-level functions written in C for greater speed that are used by the
|
||||
higher-level modules.
|
||||
|
||||
The :mod:`binascii` module defines the following functions:
|
||||
|
||||
|
@ -74,8 +74,8 @@ Handling of compressed files is offered by the :class:`BZ2File` class.
|
||||
|
||||
.. method:: BZ2File.readline([size])
|
||||
|
||||
Return the next line from the file, as a string, retaining newline. A non-
|
||||
negative *size* argument limits the maximum number of bytes to return (an
|
||||
Return the next line from the file, as a string, retaining newline. A
|
||||
non-negative *size* argument limits the maximum number of bytes to return (an
|
||||
incomplete line may be returned then). Return an empty string at EOF.
|
||||
|
||||
|
||||
|
@ -552,7 +552,7 @@ Common problems and solutions
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#] Note that some recent versions of the HTML specification do state what order the
|
||||
field values should be supplied in, but knowing whether a request was received
|
||||
from a conforming browser, or even from a browser at all, is tedious and error-
|
||||
prone.
|
||||
field values should be supplied in, but knowing whether a request was
|
||||
received from a conforming browser, or even from a browser at all, is tedious
|
||||
and error-prone.
|
||||
|
||||
|
@ -53,18 +53,18 @@ instance will fail with a :exc:`EOFError` exception.
|
||||
|
||||
.. class:: Chunk(file[, align, bigendian, inclheader])
|
||||
|
||||
Class which represents a chunk. The *file* argument is expected to be a file-
|
||||
like object. An instance of this class is specifically allowed. The only
|
||||
method that is needed is :meth:`read`. If the methods :meth:`seek` and
|
||||
:meth:`tell` are present and don't raise an exception, they are also used. If
|
||||
these methods are present and raise an exception, they are expected to not have
|
||||
altered the object. If the optional argument *align* is true, chunks are
|
||||
assumed to be aligned on 2-byte boundaries. If *align* is false, no alignment
|
||||
is assumed. The default value is true. If the optional argument *bigendian* is
|
||||
false, the chunk size is assumed to be in little-endian order. This is needed
|
||||
for WAVE audio files. The default value is true. If the optional argument
|
||||
*inclheader* is true, the size given in the chunk header includes the size of
|
||||
the header. The default value is false.
|
||||
Class which represents a chunk. The *file* argument is expected to be a
|
||||
file-like object. An instance of this class is specifically allowed. The
|
||||
only method that is needed is :meth:`read`. If the methods :meth:`seek` and
|
||||
:meth:`tell` are present and don't raise an exception, they are also used.
|
||||
If these methods are present and raise an exception, they are expected to not
|
||||
have altered the object. If the optional argument *align* is true, chunks
|
||||
are assumed to be aligned on 2-byte boundaries. If *align* is false, no
|
||||
alignment is assumed. The default value is true. If the optional argument
|
||||
*bigendian* is false, the chunk size is assumed to be in little-endian order.
|
||||
This is needed for WAVE audio files. The default value is true. If the
|
||||
optional argument *inclheader* is true, the size given in the chunk header
|
||||
includes the size of the header. The default value is false.
|
||||
|
||||
A :class:`Chunk` object supports the following methods:
|
||||
|
||||
|
@ -7,12 +7,12 @@
|
||||
|
||||
|
||||
This module is always available. It provides access to mathematical functions
|
||||
for complex numbers. The functions in this module accept integers, floating-
|
||||
point numbers or complex numbers as arguments. They will also accept any Python
|
||||
object that has either a :meth:`__complex__` or a :meth:`__float__` method:
|
||||
these methods are used to convert the object to a complex or floating-point
|
||||
number, respectively, and the function is then applied to the result of the
|
||||
conversion.
|
||||
for complex numbers. The functions in this module accept integers,
|
||||
floating-point numbers or complex numbers as arguments. They will also accept
|
||||
any Python object that has either a :meth:`__complex__` or a :meth:`__float__`
|
||||
method: these methods are used to convert the object to a complex or
|
||||
floating-point number, respectively, and the function is then applied to the
|
||||
result of the conversion.
|
||||
|
||||
The functions are:
|
||||
|
||||
|
@ -73,15 +73,15 @@ Interactive Interpreter Objects
|
||||
:func:`compile_command`; the default for *filename* is ``'<input>'``, and for
|
||||
*symbol* is ``'single'``. One several things can happen:
|
||||
|
||||
* The input is incorrect; :func:`compile_command` raised an exception
|
||||
* The input is incorrect; :func:`compile_command` raised an exception
|
||||
(:exc:`SyntaxError` or :exc:`OverflowError`). A syntax traceback will be
|
||||
printed by calling the :meth:`showsyntaxerror` method. :meth:`runsource`
|
||||
returns ``False``.
|
||||
|
||||
* The input is incomplete, and more input is required; :func:`compile_command`
|
||||
* The input is incomplete, and more input is required; :func:`compile_command`
|
||||
returned ``None``. :meth:`runsource` returns ``True``.
|
||||
|
||||
* The input is complete; :func:`compile_command` returned a code object. The
|
||||
* The input is complete; :func:`compile_command` returned a code object. The
|
||||
code is executed by calling the :meth:`runcode` (which also handles run-time
|
||||
exceptions, except for :exc:`SystemExit`). :meth:`runsource` returns ``False``.
|
||||
|
||||
|
@ -30,19 +30,19 @@ It defines the following functions:
|
||||
argument, the encoding name in all lower case letters, and return a
|
||||
:class:`CodecInfo` object having the following attributes:
|
||||
|
||||
* ``name`` The name of the encoding;
|
||||
* ``name`` The name of the encoding;
|
||||
|
||||
* ``encoder`` The stateless encoding function;
|
||||
* ``encoder`` The stateless encoding function;
|
||||
|
||||
* ``decoder`` The stateless decoding function;
|
||||
* ``decoder`` The stateless decoding function;
|
||||
|
||||
* ``incrementalencoder`` An incremental encoder class or factory function;
|
||||
* ``incrementalencoder`` An incremental encoder class or factory function;
|
||||
|
||||
* ``incrementaldecoder`` An incremental decoder class or factory function;
|
||||
* ``incrementaldecoder`` An incremental decoder class or factory function;
|
||||
|
||||
* ``streamwriter`` A stream writer class or factory function;
|
||||
* ``streamwriter`` A stream writer class or factory function;
|
||||
|
||||
* ``streamreader`` A stream reader class or factory function.
|
||||
* ``streamreader`` A stream reader class or factory function.
|
||||
|
||||
The various functions or classes take the following arguments:
|
||||
|
||||
@ -408,15 +408,15 @@ define in order to be compatible with the Python codec registry.
|
||||
The :class:`IncrementalEncoder` may implement different error handling schemes
|
||||
by providing the *errors* keyword argument. These parameters are predefined:
|
||||
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
|
||||
* ``'replace'`` Replace with a suitable replacement character
|
||||
* ``'replace'`` Replace with a suitable replacement character
|
||||
|
||||
* ``'xmlcharrefreplace'`` Replace with the appropriate XML character reference
|
||||
* ``'xmlcharrefreplace'`` Replace with the appropriate XML character reference
|
||||
|
||||
* ``'backslashreplace'`` Replace with backslashed escape sequences.
|
||||
* ``'backslashreplace'`` Replace with backslashed escape sequences.
|
||||
|
||||
The *errors* argument will be assigned to an attribute of the same name.
|
||||
Assigning to this attribute makes it possible to switch between different error
|
||||
@ -460,11 +460,11 @@ define in order to be compatible with the Python codec registry.
|
||||
The :class:`IncrementalDecoder` may implement different error handling schemes
|
||||
by providing the *errors* keyword argument. These parameters are predefined:
|
||||
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
|
||||
* ``'replace'`` Replace with a suitable replacement character.
|
||||
* ``'replace'`` Replace with a suitable replacement character.
|
||||
|
||||
The *errors* argument will be assigned to an attribute of the same name.
|
||||
Assigning to this attribute makes it possible to switch between different error
|
||||
@ -518,15 +518,15 @@ compatible with the Python codec registry.
|
||||
The :class:`StreamWriter` may implement different error handling schemes by
|
||||
providing the *errors* keyword argument. These parameters are predefined:
|
||||
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
|
||||
* ``'replace'`` Replace with a suitable replacement character
|
||||
* ``'replace'`` Replace with a suitable replacement character
|
||||
|
||||
* ``'xmlcharrefreplace'`` Replace with the appropriate XML character reference
|
||||
* ``'xmlcharrefreplace'`` Replace with the appropriate XML character reference
|
||||
|
||||
* ``'backslashreplace'`` Replace with backslashed escape sequences.
|
||||
* ``'backslashreplace'`` Replace with backslashed escape sequences.
|
||||
|
||||
The *errors* argument will be assigned to an attribute of the same name.
|
||||
Assigning to this attribute makes it possible to switch between different error
|
||||
@ -582,11 +582,11 @@ compatible with the Python codec registry.
|
||||
The :class:`StreamReader` may implement different error handling schemes by
|
||||
providing the *errors* keyword argument. These parameters are defined:
|
||||
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
* ``'strict'`` Raise :exc:`ValueError` (or a subclass); this is the default.
|
||||
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
* ``'ignore'`` Ignore the character and continue with the next.
|
||||
|
||||
* ``'replace'`` Replace with a suitable replacement character.
|
||||
* ``'replace'`` Replace with a suitable replacement character.
|
||||
|
||||
The *errors* argument will be assigned to an attribute of the same name.
|
||||
Assigning to this attribute makes it possible to switch between different error
|
||||
|
@ -10,10 +10,11 @@
|
||||
|
||||
.. % LaTeXed from excellent doc-string.
|
||||
|
||||
The :mod:`codeop` module provides utilities upon which the Python read-eval-
|
||||
print loop can be emulated, as is done in the :mod:`code` module. As a result,
|
||||
you probably don't want to use the module directly; if you want to include such
|
||||
a loop in your program you probably want to use the :mod:`code` module instead.
|
||||
The :mod:`codeop` module provides utilities upon which the Python
|
||||
read-eval-print loop can be emulated, as is done in the :mod:`code` module. As
|
||||
a result, you probably don't want to use the module directly; if you want to
|
||||
include such a loop in your program you probably want to use the :mod:`code`
|
||||
module instead.
|
||||
|
||||
There are two parts to this job:
|
||||
|
||||
|
@ -145,19 +145,13 @@ Morsel Objects
|
||||
Morsels are dictionary-like objects, whose set of keys is constant --- the valid
|
||||
:rfc:`2109` attributes, which are
|
||||
|
||||
* ``expires``
|
||||
|
||||
* ``path``
|
||||
|
||||
* ``comment``
|
||||
|
||||
* ``domain``
|
||||
|
||||
* ``max-age``
|
||||
|
||||
* ``secure``
|
||||
|
||||
* ``version``
|
||||
* ``expires``
|
||||
* ``path``
|
||||
* ``comment``
|
||||
* ``domain``
|
||||
* ``max-age``
|
||||
* ``secure``
|
||||
* ``version``
|
||||
|
||||
The keys are case-insensitive.
|
||||
|
||||
|
@ -94,10 +94,10 @@ The following classes are provided:
|
||||
received in a :mailheader:`Set-Cookie` header with a version cookie-attribute of
|
||||
1) are treated according to the RFC 2965 rules. However, if RFC 2965 handling
|
||||
is turned off or :attr:`rfc2109_as_netscape` is True, RFC 2109 cookies are
|
||||
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by setting
|
||||
the :attr:`version` attribute of the :class:`Cookie` instance to 0.
|
||||
:class:`DefaultCookiePolicy` also provides some parameters to allow some fine-
|
||||
tuning of policy.
|
||||
'downgraded' by the :class:`CookieJar` instance to Netscape cookies, by
|
||||
setting the :attr:`version` attribute of the :class:`Cookie` instance to 0.
|
||||
:class:`DefaultCookiePolicy` also provides some parameters to allow some
|
||||
fine-tuning of policy.
|
||||
|
||||
|
||||
.. class:: Cookie()
|
||||
@ -320,8 +320,8 @@ http://wwwsearch.sf.net/ClientCookie/.
|
||||
|
||||
.. note::
|
||||
|
||||
This loses information about RFC 2965 cookies, and also about newer or non-
|
||||
standard cookie-attributes such as ``port``.
|
||||
This loses information about RFC 2965 cookies, and also about newer or
|
||||
non-standard cookie-attributes such as ``port``.
|
||||
|
||||
.. warning::
|
||||
|
||||
@ -608,9 +608,10 @@ Cookie Objects
|
||||
:class:`Cookie` instances have Python attributes roughly corresponding to the
|
||||
standard cookie-attributes specified in the various cookie standards. The
|
||||
correspondence is not one-to-one, because there are complicated rules for
|
||||
assigning default values, because the ``max-age`` and ``expires`` cookie-
|
||||
attributes contain equivalent information, and because RFC 2109 cookies may be
|
||||
'downgraded' by :mod:`cookielib` from version 1 to version 0 (Netscape) cookies.
|
||||
assigning default values, because the ``max-age`` and ``expires``
|
||||
cookie-attributes contain equivalent information, and because RFC 2109 cookies
|
||||
may be 'downgraded' by :mod:`cookielib` from version 1 to version 0 (Netscape)
|
||||
cookies.
|
||||
|
||||
Assignment to these attributes should not be necessary other than in rare
|
||||
circumstances in a :class:`CookiePolicy` method. The class does not enforce
|
||||
@ -676,11 +677,11 @@ internal consistency, so you should know what you're doing if you do that.
|
||||
|
||||
.. attribute:: Cookie.rfc2109
|
||||
|
||||
True if this cookie was received as an RFC 2109 cookie (ie. the cookie arrived
|
||||
in a :mailheader:`Set-Cookie` header, and the value of the Version cookie-
|
||||
attribute in that header was 1). This attribute is provided because
|
||||
:mod:`cookielib` may 'downgrade' RFC 2109 cookies to Netscape cookies, in which
|
||||
case :attr:`version` is 0.
|
||||
True if this cookie was received as an RFC 2109 cookie (ie. the cookie
|
||||
arrived in a :mailheader:`Set-Cookie` header, and the value of the Version
|
||||
cookie-attribute in that header was 1). This attribute is provided because
|
||||
:mod:`cookielib` may 'downgrade' RFC 2109 cookies to Netscape cookies, in
|
||||
which case :attr:`version` is 0.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
|
@ -59,7 +59,7 @@ Module Contents
|
||||
The :mod:`csv` module defines the following functions:
|
||||
|
||||
|
||||
.. function:: reader(csvfile[, dialect=``'excel'``][, fmtparam])
|
||||
.. function:: reader(csvfile[, dialect='excel'][, fmtparam])
|
||||
|
||||
Return a reader object which will iterate over lines in the given *csvfile*.
|
||||
*csvfile* can be any object which supports the iterator protocol and returns a
|
||||
@ -87,7 +87,7 @@ The :mod:`csv` module defines the following functions:
|
||||
be split into lines in a manner which preserves the newline characters.
|
||||
|
||||
|
||||
.. function:: writer(csvfile[, dialect=``'excel'``][, fmtparam])
|
||||
.. function:: writer(csvfile[, dialect='excel'][, fmtparam])
|
||||
|
||||
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
|
||||
@ -143,7 +143,7 @@ The :mod:`csv` module defines the following functions:
|
||||
The :mod:`csv` module defines the following classes:
|
||||
|
||||
|
||||
.. class:: DictReader(csvfile[, fieldnames=:const:`None`,[, restkey=:const:`None`[, restval=:const:`None`[, dialect=``'excel'``[, *args, **kwds]]]]])
|
||||
.. class:: DictReader(csvfile[, fieldnames=:const:None,[, restkey=:const: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.
|
||||
@ -157,7 +157,7 @@ The :mod:`csv` module defines the following classes:
|
||||
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
|
||||
@ -202,7 +202,7 @@ The :mod:`csv` module defines the following classes:
|
||||
The :class:`Sniffer` class provides two methods:
|
||||
|
||||
|
||||
.. method:: Sniffer.sniff(sample[,delimiters=None])
|
||||
.. method:: Sniffer.sniff(sample[, delimiters=None])
|
||||
|
||||
Analyze the given *sample* and return a :class:`Dialect` subclass reflecting the
|
||||
parameters found. If the optional *delimiters* parameter is given, it is
|
||||
|
@ -1910,9 +1910,9 @@ Utility functions
|
||||
|
||||
.. function:: string_at(address[, size])
|
||||
|
||||
This function returns the string starting at memory address address. If size is
|
||||
specified, it is used as size, otherwise the string is assumed to be zero-
|
||||
terminated.
|
||||
This function returns the string starting at memory address address. If size
|
||||
is specified, it is used as size, otherwise the string is assumed to be
|
||||
zero-terminated.
|
||||
|
||||
|
||||
.. function:: WinError(code=None, descr=None)
|
||||
@ -1928,8 +1928,8 @@ Utility functions
|
||||
|
||||
This function returns the wide character string starting at memory address
|
||||
``address`` as unicode string. If ``size`` is specified, it is used as the
|
||||
number of characters of the string, otherwise the string is assumed to be zero-
|
||||
terminated.
|
||||
number of characters of the string, otherwise the string is assumed to be
|
||||
zero-terminated.
|
||||
|
||||
|
||||
.. _ctypes-data-types:
|
||||
@ -2198,9 +2198,9 @@ These are the fundamental ctypes data types:
|
||||
|
||||
.. class:: c_wchar_p
|
||||
|
||||
Represents the C ``wchar_t *`` datatype, which must be a pointer to a zero-
|
||||
terminated wide character string. The constructor accepts an integer address, or
|
||||
a string.
|
||||
Represents the C ``wchar_t *`` datatype, which must be a pointer to a
|
||||
zero-terminated wide character string. The constructor accepts an integer
|
||||
address, or a string.
|
||||
|
||||
|
||||
.. class:: c_bool
|
||||
|
@ -11,8 +11,8 @@
|
||||
.. versionchanged:: 1.6
|
||||
Added support for the ``ncurses`` library and converted to a package.
|
||||
|
||||
The :mod:`curses` module provides an interface to the curses library, the de-
|
||||
facto standard for portable advanced terminal handling.
|
||||
The :mod:`curses` module provides an interface to the curses library, the
|
||||
de-facto standard for portable advanced terminal handling.
|
||||
|
||||
While curses is most widely used in the Unix environment, versions are available
|
||||
for DOS, OS/2, and possibly other systems as well. This extension module is
|
||||
@ -641,10 +641,10 @@ the following methods:
|
||||
attributes *attr*. The change is then applied to every character position in
|
||||
that window:
|
||||
|
||||
* The attribute of every character in the window is changed to the new
|
||||
* The attribute of every character in the window is changed to the new
|
||||
background attribute.
|
||||
|
||||
* Wherever the former background character appears, it is changed to the new
|
||||
* Wherever the former background character appears, it is changed to the new
|
||||
background character.
|
||||
|
||||
|
||||
@ -1023,7 +1023,7 @@ the following methods:
|
||||
*sminrow*, or *smincol* are treated as if they were zero.
|
||||
|
||||
|
||||
.. method:: window.scroll([lines\ ``= 1``])
|
||||
.. method:: window.scroll([lines=1])
|
||||
|
||||
Scroll the screen or scrolling region upward by *lines* lines.
|
||||
|
||||
@ -1526,8 +1526,8 @@ The following table lists the predefined colors:
|
||||
The :mod:`curses.textpad` module provides a :class:`Textbox` class that handles
|
||||
elementary text editing in a curses window, supporting a set of keybindings
|
||||
resembling those of Emacs (thus, also of Netscape Navigator, BBedit 6.x,
|
||||
FrameMaker, and many other programs). The module also provides a rectangle-
|
||||
drawing function useful for framing text boxes or for other purposes.
|
||||
FrameMaker, and many other programs). The module also provides a
|
||||
rectangle-drawing function useful for framing text boxes or for other purposes.
|
||||
|
||||
The module :mod:`curses.textpad` defines the following function:
|
||||
|
||||
|
@ -139,22 +139,17 @@ dates or times.
|
||||
Only *days*, *seconds* and *microseconds* are stored internally. Arguments are
|
||||
converted to those units:
|
||||
|
||||
* A millisecond is converted to 1000 microseconds.
|
||||
|
||||
* A minute is converted to 60 seconds.
|
||||
|
||||
* An hour is converted to 3600 seconds.
|
||||
|
||||
* A week is converted to 7 days.
|
||||
* A millisecond is converted to 1000 microseconds.
|
||||
* A minute is converted to 60 seconds.
|
||||
* An hour is converted to 3600 seconds.
|
||||
* A week is converted to 7 days.
|
||||
|
||||
and days, seconds and microseconds are then normalized so that the
|
||||
representation is unique, with
|
||||
|
||||
* ``0 <= microseconds < 1000000``
|
||||
|
||||
* ``0 <= seconds < 3600*24`` (the number of seconds in one day)
|
||||
|
||||
* ``-999999999 <= days <= 999999999``
|
||||
* ``0 <= microseconds < 1000000``
|
||||
* ``0 <= seconds < 3600*24`` (the number of seconds in one day)
|
||||
* ``-999999999 <= days <= 999999999``
|
||||
|
||||
If any argument is a float and there are fractional microseconds, the fractional
|
||||
microseconds left over from all arguments are combined and their sum is rounded
|
||||
@ -291,11 +286,9 @@ systems.
|
||||
All arguments are required. Arguments may be ints or longs, in the following
|
||||
ranges:
|
||||
|
||||
* ``MINYEAR <= year <= MAXYEAR``
|
||||
|
||||
* ``1 <= month <= 12``
|
||||
|
||||
* ``1 <= day <= number of days in the given month and year``
|
||||
* ``MINYEAR <= year <= MAXYEAR``
|
||||
* ``1 <= month <= 12``
|
||||
* ``1 <= day <= number of days in the given month and year``
|
||||
|
||||
If an argument outside those ranges is given, :exc:`ValueError` is raised.
|
||||
|
||||
@ -514,19 +507,13 @@ Constructor:
|
||||
instance of a :class:`tzinfo` subclass. The remaining arguments may be ints or
|
||||
longs, in the following ranges:
|
||||
|
||||
* ``MINYEAR <= year <= MAXYEAR``
|
||||
|
||||
* ``1 <= month <= 12``
|
||||
|
||||
* ``1 <= day <= number of days in the given month and year``
|
||||
|
||||
* ``0 <= hour < 24``
|
||||
|
||||
* ``0 <= minute < 60``
|
||||
|
||||
* ``0 <= second < 60``
|
||||
|
||||
* ``0 <= microsecond < 1000000``
|
||||
* ``MINYEAR <= year <= MAXYEAR``
|
||||
* ``1 <= month <= 12``
|
||||
* ``1 <= day <= number of days in the given month and year``
|
||||
* ``0 <= hour < 24``
|
||||
* ``0 <= minute < 60``
|
||||
* ``0 <= second < 60``
|
||||
* ``0 <= microsecond < 1000000``
|
||||
|
||||
If an argument outside those ranges is given, :exc:`ValueError` is raised.
|
||||
|
||||
@ -894,13 +881,14 @@ Instance methods:
|
||||
|
||||
.. method:: datetime.isoformat([sep])
|
||||
|
||||
Return a string representing the date and time in ISO 8601 format, YYYY-MM-
|
||||
DDTHH:MM:SS.mmmmmm or, if :attr:`microsecond` is 0, YYYY-MM-DDTHH:MM:SS
|
||||
Return a string representing the date and time in ISO 8601 format,
|
||||
YYYY-MM-DDTHH:MM:SS.mmmmmm or, if :attr:`microsecond` is 0,
|
||||
YYYY-MM-DDTHH:MM:SS
|
||||
|
||||
If :meth:`utcoffset` does not return ``None``, a 6-character string is appended,
|
||||
giving the UTC offset in (signed) hours and minutes: YYYY-MM-
|
||||
DDTHH:MM:SS.mmmmmm+HH:MM or, if :attr:`microsecond` is 0 YYYY-MM-
|
||||
DDTHH:MM:SS+HH:MM
|
||||
If :meth:`utcoffset` does not return ``None``, a 6-character string is
|
||||
appended, giving the UTC offset in (signed) hours and minutes:
|
||||
YYYY-MM-DDTHH:MM:SS.mmmmmm+HH:MM or, if :attr:`microsecond` is 0
|
||||
YYYY-MM-DDTHH:MM:SS+HH:MM
|
||||
|
||||
The optional argument *sep* (default ``'T'``) is a one-character separator,
|
||||
placed between the date and time portions of the result. For example, ::
|
||||
@ -949,13 +937,10 @@ day, and subject to adjustment via a :class:`tzinfo` object.
|
||||
:class:`tzinfo` subclass. The remaining arguments may be ints or longs, in the
|
||||
following ranges:
|
||||
|
||||
* ``0 <= hour < 24``
|
||||
|
||||
* ``0 <= minute < 60``
|
||||
|
||||
* ``0 <= second < 60``
|
||||
|
||||
* ``0 <= microsecond < 1000000``.
|
||||
* ``0 <= hour < 24``
|
||||
* ``0 <= minute < 60``
|
||||
* ``0 <= second < 60``
|
||||
* ``0 <= microsecond < 1000000``.
|
||||
|
||||
If an argument outside those ranges is given, :exc:`ValueError` is raised. All
|
||||
default to ``0`` except *tzinfo*, which defaults to :const:`None`.
|
||||
|
@ -509,19 +509,13 @@ In addition to the three supplied contexts, new contexts can be created with the
|
||||
|
||||
The *rounding* option is one of:
|
||||
|
||||
* :const:`ROUND_CEILING` (towards :const:`Infinity`),
|
||||
|
||||
* :const:`ROUND_DOWN` (towards zero),
|
||||
|
||||
* :const:`ROUND_FLOOR` (towards :const:`-Infinity`),
|
||||
|
||||
* :const:`ROUND_HALF_DOWN` (to nearest with ties going towards zero),
|
||||
|
||||
* :const:`ROUND_HALF_EVEN` (to nearest with ties going to nearest even integer),
|
||||
|
||||
* :const:`ROUND_HALF_UP` (to nearest with ties going away from zero), or
|
||||
|
||||
* :const:`ROUND_UP` (away from zero).
|
||||
* :const:`ROUND_CEILING` (towards :const:`Infinity`),
|
||||
* :const:`ROUND_DOWN` (towards zero),
|
||||
* :const:`ROUND_FLOOR` (towards :const:`-Infinity`),
|
||||
* :const:`ROUND_HALF_DOWN` (to nearest with ties going towards zero),
|
||||
* :const:`ROUND_HALF_EVEN` (to nearest with ties going to nearest even integer),
|
||||
* :const:`ROUND_HALF_UP` (to nearest with ties going away from zero), or
|
||||
* :const:`ROUND_UP` (away from zero).
|
||||
|
||||
The *traps* and *flags* fields list any signals to be set. Generally, new
|
||||
contexts should only set traps and leave the flags clear.
|
||||
@ -1260,10 +1254,10 @@ representation issues associated with binary floating point::
|
||||
Q. Within a complex calculation, how can I make sure that I haven't gotten a
|
||||
spurious result because of insufficient precision or rounding anomalies.
|
||||
|
||||
A. The decimal module makes it easy to test results. A best practice is to re-
|
||||
run calculations using greater precision and with various rounding modes. Widely
|
||||
differing results indicate insufficient precision, rounding mode issues, ill-
|
||||
conditioned inputs, or a numerically unstable algorithm.
|
||||
A. The decimal module makes it easy to test results. A best practice is to
|
||||
re-run calculations using greater precision and with various rounding modes.
|
||||
Widely differing results indicate insufficient precision, rounding mode issues,
|
||||
ill-conditioned inputs, or a numerically unstable algorithm.
|
||||
|
||||
Q. I noticed that context precision is applied to the results of operations but
|
||||
not to the inputs. Is there anything to watch out for when mixing values of
|
||||
|
@ -34,10 +34,10 @@
|
||||
|
||||
.. class:: Differ
|
||||
|
||||
This is a class for comparing sequences of lines of text, and producing human-
|
||||
readable differences or deltas. Differ uses :class:`SequenceMatcher` both to
|
||||
compare sequences of lines, and to compare sequences of characters within
|
||||
similar (near-matching) lines.
|
||||
This is a class for comparing sequences of lines of text, and producing
|
||||
human-readable differences or deltas. Differ uses :class:`SequenceMatcher`
|
||||
both to compare sequences of lines, and to compare sequences of characters
|
||||
within similar (near-matching) lines.
|
||||
|
||||
Each line of a :class:`Differ` delta begins with a two-letter code:
|
||||
|
||||
|
@ -50,19 +50,13 @@ The :mod:`dis` module defines the following functions and constants:
|
||||
Disassembles a code object, indicating the last instruction if *lasti* was
|
||||
provided. The output is divided in the following columns:
|
||||
|
||||
#. the line number, for the first instruction of each line
|
||||
|
||||
#. the current instruction, indicated as ``-->``,
|
||||
|
||||
#. a labelled instruction, indicated with ``>>``,
|
||||
|
||||
#. the address of the instruction,
|
||||
|
||||
#. the operation code name,
|
||||
|
||||
#. operation parameters, and
|
||||
|
||||
#. interpretation of the parameters in parentheses.
|
||||
#. the line number, for the first instruction of each line
|
||||
#. the current instruction, indicated as ``-->``,
|
||||
#. a labelled instruction, indicated with ``>>``,
|
||||
#. the address of the instruction,
|
||||
#. the operation code name,
|
||||
#. operation parameters, and
|
||||
#. interpretation of the parameters in parentheses.
|
||||
|
||||
The parameter interpretation recognizes local and global variable names,
|
||||
constant values, branch targets, and compare operators.
|
||||
@ -541,8 +535,8 @@ the more significant byte last.
|
||||
|
||||
.. opcode:: UNPACK_SEQUENCE (count)
|
||||
|
||||
Unpacks TOS into *count* individual values, which are put onto the stack right-
|
||||
to-left.
|
||||
Unpacks TOS into *count* individual values, which are put onto the stack
|
||||
right-to-left.
|
||||
|
||||
.. % \begin{opcodedesc}{UNPACK_LIST}{count}
|
||||
.. % This opcode is obsolete.
|
||||
|
@ -28,7 +28,7 @@ libraries. It allows the program to call arbitrary functions in such a library.
|
||||
The :mod:`dl` module defines the following function:
|
||||
|
||||
|
||||
.. function:: open(name[, mode\ ``= RTLD_LAZY``])
|
||||
.. function:: open(name[, mode=RTLD_LAZY])
|
||||
|
||||
Open a shared object file, and return a handle. Mode signifies late binding
|
||||
(:const:`RTLD_LAZY`) or immediate binding (:const:`RTLD_NOW`). Default is
|
||||
|
@ -435,10 +435,10 @@ The traceback header is followed by an optional traceback stack, whose contents
|
||||
are ignored by doctest. The traceback stack is typically omitted, or copied
|
||||
verbatim from an interactive session.
|
||||
|
||||
The traceback stack is followed by the most interesting part: the line(s)
|
||||
The traceback stack is followed by the most interesting part: the line(s)
|
||||
containing the exception type and detail. This is usually the last line of a
|
||||
traceback, but can extend across multiple lines if the exception has a multi-
|
||||
line detail::
|
||||
traceback, but can extend across multiple lines if the exception has a
|
||||
multi-line detail::
|
||||
|
||||
>>> raise ValueError('multi\n line\ndetail')
|
||||
Traceback (most recent call last):
|
||||
@ -823,14 +823,14 @@ and :ref:`doctest-simple-testfile`.
|
||||
Optional argument *module_relative* specifies how the filename should be
|
||||
interpreted:
|
||||
|
||||
* If *module_relative* is ``True`` (the default), then *filename* specifies an
|
||||
* If *module_relative* is ``True`` (the default), then *filename* specifies an
|
||||
OS-independent module-relative path. By default, this path is relative to the
|
||||
calling module's directory; but if the *package* argument is specified, then it
|
||||
is relative to that package. To ensure OS-independence, *filename* should use
|
||||
``/`` characters to separate path segments, and may not be an absolute path
|
||||
(i.e., it may not begin with ``/``).
|
||||
|
||||
* If *module_relative* is ``False``, then *filename* specifies an OS-specific
|
||||
* If *module_relative* is ``False``, then *filename* specifies an OS-specific
|
||||
path. The path may be absolute or relative; relative paths are resolved with
|
||||
respect to the current working directory.
|
||||
|
||||
@ -1000,14 +1000,14 @@ from text files and modules with doctests:
|
||||
Optional argument *module_relative* specifies how the filenames in *paths*
|
||||
should be interpreted:
|
||||
|
||||
* If *module_relative* is ``True`` (the default), then each filename specifies
|
||||
* If *module_relative* is ``True`` (the default), then each filename specifies
|
||||
an OS-independent module-relative path. By default, this path is relative to
|
||||
the calling module's directory; but if the *package* argument is specified, then
|
||||
it is relative to that package. To ensure OS-independence, each filename should
|
||||
use ``/`` characters to separate path segments, and may not be an absolute path
|
||||
(i.e., it may not begin with ``/``).
|
||||
|
||||
* If *module_relative* is ``False``, then each filename specifies an OS-specific
|
||||
* If *module_relative* is ``False``, then each filename specifies an OS-specific
|
||||
path. The path may be absolute or relative; relative paths are resolved with
|
||||
respect to the current working directory.
|
||||
|
||||
@ -1074,8 +1074,8 @@ from text files and modules with doctests:
|
||||
Optional argument *extraglobs* specifies an extra set of global variables, which
|
||||
is merged into *globs*. By default, no extra globals are used.
|
||||
|
||||
Optional argument *test_finder* is the :class:`DocTestFinder` object (or a drop-
|
||||
in replacement) that is used to extract doctests from the module.
|
||||
Optional argument *test_finder* is the :class:`DocTestFinder` object (or a
|
||||
drop-in replacement) that is used to extract doctests from the module.
|
||||
|
||||
Optional arguments *setUp*, *tearDown*, and *optionflags* are the same as for
|
||||
function :func:`DocFileSuite` above.
|
||||
@ -1346,15 +1346,15 @@ DocTestFinder objects
|
||||
If the module is not specified or is None, then the test finder will attempt to
|
||||
automatically determine the correct module. The object's module is used:
|
||||
|
||||
* As a default namespace, if *globs* is not specified.
|
||||
* As a default namespace, if *globs* is not specified.
|
||||
|
||||
* To prevent the DocTestFinder from extracting DocTests from objects that are
|
||||
* To prevent the DocTestFinder from extracting DocTests from objects that are
|
||||
imported from other modules. (Contained objects with modules other than
|
||||
*module* are ignored.)
|
||||
|
||||
* To find the name of the file containing the object.
|
||||
* To find the name of the file containing the object.
|
||||
|
||||
* To help find the line number of the object within its file.
|
||||
* To help find the line number of the object within its file.
|
||||
|
||||
If *module* is ``False``, no attempt to find the module will be made. This is
|
||||
obscure, of use mostly in testing doctest itself: if *module* is ``False``, or
|
||||
|
@ -149,8 +149,8 @@ Import this class from the :mod:`email.charset` module.
|
||||
|
||||
.. method:: Charset.encoded_header_len()
|
||||
|
||||
Return the length of the encoded header string, properly calculating for quoted-
|
||||
printable or base64 encoding.
|
||||
Return the length of the encoded header string, properly calculating for
|
||||
quoted-printable or base64 encoding.
|
||||
|
||||
|
||||
.. method:: Charset.header_encode(s[, convert])
|
||||
@ -210,11 +210,11 @@ new entries to the global character set, alias, and codec registries:
|
||||
*charset* is the input character set, and must be the canonical name of a
|
||||
character set.
|
||||
|
||||
Optional *header_enc* and *body_enc* is either ``Charset.QP`` for quoted-
|
||||
printable, ``Charset.BASE64`` for base64 encoding, ``Charset.SHORTEST`` for the
|
||||
shortest of quoted-printable or base64 encoding, or ``None`` for no encoding.
|
||||
``SHORTEST`` is only valid for *header_enc*. The default is ``None`` for no
|
||||
encoding.
|
||||
Optional *header_enc* and *body_enc* is either ``Charset.QP`` for
|
||||
quoted-printable, ``Charset.BASE64`` for base64 encoding,
|
||||
``Charset.SHORTEST`` for the shortest of quoted-printable or base64 encoding,
|
||||
or ``None`` for no encoding. ``SHORTEST`` is only valid for
|
||||
*header_enc*. The default is ``None`` for no encoding.
|
||||
|
||||
Optional *output_charset* is the character set that the output should be in.
|
||||
Conversions will proceed from input charset, to Unicode, to the output charset
|
||||
|
@ -100,17 +100,17 @@ representing the part.
|
||||
string that is used instead of the message payload. *fmt* is expanded with the
|
||||
following keywords, ``%(keyword)s`` format:
|
||||
|
||||
* ``type`` -- Full MIME type of the non-\ :mimetype:`text` part
|
||||
* ``type`` -- Full MIME type of the non-\ :mimetype:`text` part
|
||||
|
||||
* ``maintype`` -- Main MIME type of the non-\ :mimetype:`text` part
|
||||
* ``maintype`` -- Main MIME type of the non-\ :mimetype:`text` part
|
||||
|
||||
* ``subtype`` -- Sub-MIME type of the non-\ :mimetype:`text` part
|
||||
* ``subtype`` -- Sub-MIME type of the non-\ :mimetype:`text` part
|
||||
|
||||
* ``filename`` -- Filename of the non-\ :mimetype:`text` part
|
||||
* ``filename`` -- Filename of the non-\ :mimetype:`text` part
|
||||
|
||||
* ``description`` -- Description associated with the non-\ :mimetype:`text` part
|
||||
* ``description`` -- Description associated with the non-\ :mimetype:`text` part
|
||||
|
||||
* ``encoding`` -- Content transfer encoding of the non-\ :mimetype:`text` part
|
||||
* ``encoding`` -- Content transfer encoding of the non-\ :mimetype:`text` part
|
||||
|
||||
The default value for *fmt* is ``None``, meaning ::
|
||||
|
||||
|
@ -15,10 +15,10 @@ Headers are :rfc:`2822` style field names and values where the field name and
|
||||
value are separated by a colon. The colon is not part of either the field name
|
||||
or the field value.
|
||||
|
||||
Headers are stored and returned in case-preserving form but are matched case-
|
||||
insensitively. There may also be a single envelope header, also known as the
|
||||
*Unix-From* header or the ``From_`` header. The payload is either a string in
|
||||
the case of simple message objects or a list of :class:`Message` objects for
|
||||
Headers are stored and returned in case-preserving form but are matched
|
||||
case-insensitively. There may also be a single envelope header, also known as
|
||||
the *Unix-From* header or the ``From_`` header. The payload is either a string
|
||||
in the case of simple message objects or a list of :class:`Message` objects for
|
||||
MIME container documents (e.g. :mimetype:`multipart/\*` and
|
||||
:mimetype:`message/rfc822`).
|
||||
|
||||
|
@ -51,11 +51,11 @@ and results of the two parser APIs are identical.
|
||||
The :class:`FeedParser`'s API is simple; you create an instance, feed it a bunch
|
||||
of text until there's no more to feed it, then close the parser to retrieve the
|
||||
root message object. The :class:`FeedParser` is extremely accurate when parsing
|
||||
standards-compliant messages, and it does a very good job of parsing non-
|
||||
compliant messages, providing information about how a message was deemed broken.
|
||||
It will populate a message object's *defects* attribute with a list of any
|
||||
problems it found in a message. See the :mod:`email.errors` module for the list
|
||||
of defects that it can find.
|
||||
standards-compliant messages, and it does a very good job of parsing
|
||||
non-compliant messages, providing information about how a message was deemed
|
||||
broken. It will populate a message object's *defects* attribute with a list of
|
||||
any problems it found in a message. See the :mod:`email.errors` module for the
|
||||
list of defects that it can find.
|
||||
|
||||
Here is the API for the :class:`FeedParser`:
|
||||
|
||||
@ -108,10 +108,10 @@ class.
|
||||
The optional *strict* flag is ignored.
|
||||
|
||||
.. deprecated:: 2.4
|
||||
Because the :class:`Parser` class is a backward compatible API wrapper around
|
||||
the new-in-Python 2.4 :class:`FeedParser`, *all* parsing is effectively non-
|
||||
strict. You should simply stop passing a *strict* flag to the :class:`Parser`
|
||||
constructor.
|
||||
Because the :class:`Parser` class is a backward compatible API wrapper
|
||||
around the new-in-Python 2.4 :class:`FeedParser`, *all* parsing is
|
||||
effectively non-strict. You should simply stop passing a *strict* flag to
|
||||
the :class:`Parser` constructor.
|
||||
|
||||
.. versionchanged:: 2.2.2
|
||||
The *strict* flag was added.
|
||||
@ -129,10 +129,10 @@ The other public :class:`Parser` methods are:
|
||||
the :meth:`read` methods on file-like objects.
|
||||
|
||||
The text contained in *fp* must be formatted as a block of :rfc:`2822` style
|
||||
headers and header continuation lines, optionally preceded by a envelope header.
|
||||
The header block is terminated either by the end of the data or by a blank line.
|
||||
Following the header block is the body of the message (which may contain MIME-
|
||||
encoded subparts).
|
||||
headers and header continuation lines, optionally preceded by a envelope
|
||||
header. The header block is terminated either by the end of the data or by a
|
||||
blank line. Following the header block is the body of the message (which may
|
||||
contain MIME-encoded subparts).
|
||||
|
||||
Optional *headersonly* is as with the :meth:`parse` method.
|
||||
|
||||
|
@ -8,8 +8,8 @@
|
||||
|
||||
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 :file:`linux/include/errno.h`, which should be pretty all-
|
||||
inclusive.
|
||||
borrowed from :file:`linux/include/errno.h`, which should be pretty
|
||||
all-inclusive.
|
||||
|
||||
|
||||
.. data:: errorcode
|
||||
|
@ -104,29 +104,26 @@ The module defines the following functions:
|
||||
the file descriptor of the file to lock or unlock, and *operation* is one of the
|
||||
following values:
|
||||
|
||||
* :const:`LOCK_UN` -- unlock
|
||||
* :const:`LOCK_UN` -- unlock
|
||||
* :const:`LOCK_SH` -- acquire a shared lock
|
||||
* :const:`LOCK_EX` -- acquire an exclusive lock
|
||||
|
||||
* :const:`LOCK_SH` -- acquire a shared lock
|
||||
|
||||
* :const:`LOCK_EX` -- acquire an exclusive lock
|
||||
|
||||
When *operation* is :const:`LOCK_SH` or :const:`LOCK_EX`, it can also be bit-
|
||||
wise OR'd with :const:`LOCK_NB` to avoid blocking on lock acquisition. If
|
||||
:const:`LOCK_NB` is used and the lock cannot be acquired, an :exc:`IOError` will
|
||||
be raised and the exception will have an *errno* attribute set to
|
||||
:const:`EACCES` or :const:`EAGAIN` (depending on the operating system; for
|
||||
portability, check for both values). On at least some systems, :const:`LOCK_EX`
|
||||
can only be used if the file descriptor refers to a file opened for writing.
|
||||
When *operation* is :const:`LOCK_SH` or :const:`LOCK_EX`, it can also be
|
||||
bit-wise OR'd with :const:`LOCK_NB` to avoid blocking on lock acquisition.
|
||||
If :const:`LOCK_NB` is used and the lock cannot be acquired, an
|
||||
:exc:`IOError` will be raised and the exception will have an *errno*
|
||||
attribute set to :const:`EACCES` or :const:`EAGAIN` (depending on the
|
||||
operating system; for portability, check for both values). On at least some
|
||||
systems, :const:`LOCK_EX` can only be used if the file descriptor refers to a
|
||||
file opened for writing.
|
||||
|
||||
*length* is the number of bytes to lock, *start* is the byte offset at which the
|
||||
lock starts, relative to *whence*, and *whence* is as with :func:`fileobj.seek`,
|
||||
specifically:
|
||||
|
||||
* :const:`0` -- relative to the start of the file (:const:`SEEK_SET`)
|
||||
|
||||
* :const:`1` -- relative to the current buffer position (:const:`SEEK_CUR`)
|
||||
|
||||
* :const:`2` -- relative to the end of the file (:const:`SEEK_END`)
|
||||
* :const:`0` -- relative to the start of the file (:const:`SEEK_SET`)
|
||||
* :const:`1` -- relative to the current buffer position (:const:`SEEK_CUR`)
|
||||
* :const:`2` -- relative to the end of the file (:const:`SEEK_END`)
|
||||
|
||||
The default for *start* is 0, which means to start at the beginning of the file.
|
||||
The default for *length* is 0 which means to lock to the end of the file. The
|
||||
@ -151,7 +148,8 @@ lay-out for the *lockdata* variable is system dependent --- therefore using the
|
||||
.. seealso::
|
||||
|
||||
Module :mod:`os`
|
||||
If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present in the
|
||||
:mod:`os` module, the :func:`os.open` function provides a more platform-
|
||||
independent alternative to the :func:`lockf` and :func:`flock` functions.
|
||||
If the locking flags :const:`O_SHLOCK` and :const:`O_EXLOCK` are present
|
||||
in the :mod:`os` module, the :func:`os.open` function provides a more
|
||||
platform-independent alternative to the :func:`lockf` and :func:`flock`
|
||||
functions.
|
||||
|
||||
|
@ -169,7 +169,7 @@ The following attributes are defined for formatter instance objects:
|
||||
:const:`AS_IS` values, is passed to the writer's :meth:`new_styles` method.
|
||||
|
||||
|
||||
.. method:: formatter.pop_style([n\ ``= 1``])
|
||||
.. method:: formatter.pop_style([n=1])
|
||||
|
||||
Pop the last *n* style specifications passed to :meth:`push_style`. A tuple
|
||||
representing the revised stack, including :const:`AS_IS` values, is passed to
|
||||
@ -181,12 +181,12 @@ The following attributes are defined for formatter instance objects:
|
||||
Set the spacing style for the writer.
|
||||
|
||||
|
||||
.. method:: formatter.assert_line_data([flag\ ``= 1``])
|
||||
.. method:: formatter.assert_line_data([flag=1])
|
||||
|
||||
Inform the formatter that data has been added to the current paragraph out-of-
|
||||
band. This should be used when the writer has been manipulated directly. The
|
||||
optional *flag* argument can be set to false if the writer manipulations
|
||||
produced a hard line break at the end of the output.
|
||||
Inform the formatter that data has been added to the current paragraph
|
||||
out-of-band. This should be used when the writer has been manipulated
|
||||
directly. The optional *flag* argument can be set to false if the writer
|
||||
manipulations produced a hard line break at the end of the output.
|
||||
|
||||
|
||||
.. _formatter-impls:
|
||||
@ -341,7 +341,7 @@ this module. Most applications will need to derive new writer classes from the
|
||||
output.
|
||||
|
||||
|
||||
.. class:: DumbWriter([file[, maxcol\ ``= 72``]])
|
||||
.. class:: DumbWriter([file[, maxcol=72]])
|
||||
|
||||
Simple writer class which writes output on the file object passed in as *file*
|
||||
or, if *file* is omitted, on standard output. The output is simply word-wrapped
|
||||
|
@ -17,10 +17,10 @@
|
||||
|
||||
.. index:: single: IEEE-754
|
||||
|
||||
Most computers carry out floating point operations in conformance with the so-
|
||||
called IEEE-754 standard. On any real computer, some floating point operations
|
||||
produce results that cannot be expressed as a normal floating point value. For
|
||||
example, try ::
|
||||
Most computers carry out floating point operations in conformance with the
|
||||
so-called IEEE-754 standard. On any real computer, some floating point
|
||||
operations produce results that cannot be expressed as a normal floating point
|
||||
value. For example, try ::
|
||||
|
||||
>>> import math
|
||||
>>> math.exp(1000)
|
||||
|
@ -39,16 +39,17 @@ available. They are listed here in alphabetical order.
|
||||
its *locals* argument at all, and uses its *globals* only to determine the
|
||||
package context of the :keyword:`import` statement.)
|
||||
|
||||
When the *name* variable is of the form ``package.module``, normally, the top-
|
||||
level package (the name up till the first dot) is returned, *not* the module
|
||||
named by *name*. However, when a non-empty *fromlist* argument is given, the
|
||||
module named by *name* is returned. This is done for compatibility with the
|
||||
bytecode generated for the different kinds of import statement; when using
|
||||
``import spam.ham.eggs``, the top-level package :mod:`spam` must be placed in
|
||||
the importing namespace, but when using ``from spam.ham import eggs``, the
|
||||
``spam.ham`` subpackage must be used to find the ``eggs`` variable. As a
|
||||
workaround for this behavior, use :func:`getattr` to extract the desired
|
||||
components. For example, you could define the following helper::
|
||||
When the *name* variable is of the form ``package.module``, normally, the
|
||||
top-level package (the name up till the first dot) is returned, *not* the
|
||||
module named by *name*. However, when a non-empty *fromlist* argument is
|
||||
given, the module named by *name* is returned. This is done for
|
||||
compatibility with the bytecode generated for the different kinds of import
|
||||
statement; when using ``import spam.ham.eggs``, the top-level package
|
||||
:mod:`spam` must be placed in the importing namespace, but when using ``from
|
||||
spam.ham import eggs``, the ``spam.ham`` subpackage must be used to find the
|
||||
``eggs`` variable. As a workaround for this behavior, use :func:`getattr` to
|
||||
extract the desired components. For example, you could define the following
|
||||
helper::
|
||||
|
||||
def my_import(name):
|
||||
mod = __import__(name)
|
||||
@ -259,19 +260,19 @@ available. They are listed here in alphabetical order.
|
||||
keyword is retained in the dictionary. For example, these all return a
|
||||
dictionary equal to ``{"one": 2, "two": 3}``:
|
||||
|
||||
* ``dict({'one': 2, 'two': 3})``
|
||||
* ``dict({'one': 2, 'two': 3})``
|
||||
|
||||
* ``dict({'one': 2, 'two': 3}.items())``
|
||||
* ``dict({'one': 2, 'two': 3}.items())``
|
||||
|
||||
* ``dict({'one': 2, 'two': 3}.iteritems())``
|
||||
* ``dict({'one': 2, 'two': 3}.iteritems())``
|
||||
|
||||
* ``dict(zip(('one', 'two'), (2, 3)))``
|
||||
* ``dict(zip(('one', 'two'), (2, 3)))``
|
||||
|
||||
* ``dict([['two', 3], ['one', 2]])``
|
||||
* ``dict([['two', 3], ['one', 2]])``
|
||||
|
||||
* ``dict(one=2, two=3)``
|
||||
* ``dict(one=2, two=3)``
|
||||
|
||||
* ``dict([(['one', 'two'][i-2], i) for i in (2, 3)])``
|
||||
* ``dict([(['one', 'two'][i-2], i) for i in (2, 3)])``
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
@ -924,18 +925,18 @@ available. They are listed here in alphabetical order.
|
||||
|
||||
When ``reload(module)`` is executed:
|
||||
|
||||
* Python modules' code is recompiled and the module-level code reexecuted,
|
||||
* Python modules' code is recompiled and the module-level code reexecuted,
|
||||
defining a new set of objects which are bound to names in the module's
|
||||
dictionary. The ``init`` function of extension modules is not called a second
|
||||
time.
|
||||
|
||||
* As with all other objects in Python the old objects are only reclaimed after
|
||||
* As with all other objects in Python the old objects are only reclaimed after
|
||||
their reference counts drop to zero.
|
||||
|
||||
* The names in the module namespace are updated to point to any new or changed
|
||||
* The names in the module namespace are updated to point to any new or changed
|
||||
objects.
|
||||
|
||||
* Other references to the old objects (such as names external to the module) are
|
||||
* Other references to the old objects (such as names external to the module) are
|
||||
not rebound to refer to the new objects and must be updated in each namespace
|
||||
where they occur if that is desired.
|
||||
|
||||
|
@ -40,13 +40,13 @@ The module defines the following constant and functions:
|
||||
The following additional characters may be appended to the flag to control how
|
||||
the database is opened:
|
||||
|
||||
* ``'f'`` --- Open the database in fast mode. Writes to the database will not
|
||||
* ``'f'`` --- Open the database in fast mode. Writes to the database will not
|
||||
be synchronized.
|
||||
|
||||
* ``'s'`` --- Synchronized mode. This will cause changes to the database will be
|
||||
* ``'s'`` --- Synchronized mode. This will cause changes to the database will be
|
||||
immediately written to the file.
|
||||
|
||||
* ``'u'`` --- Do not lock database.
|
||||
* ``'u'`` --- Do not lock database.
|
||||
|
||||
Not all flags are valid for all versions of ``gdbm``. The module constant
|
||||
``open_flags`` is a string of supported flag characters. The exception
|
||||
|
@ -43,13 +43,13 @@ exception:
|
||||
|
||||
The return value consists of two elements: the first is a list of ``(option,
|
||||
value)`` pairs; the second is the list of program arguments left after the
|
||||
option list was stripped (this is a trailing slice of *args*). Each option-and-
|
||||
value pair returned has the option as its first element, prefixed with a hyphen
|
||||
for short options (e.g., ``'-x'``) or two hyphens for long options (e.g.,
|
||||
``'-``\ ``-long-option'``), and the option argument as its second element, or an
|
||||
empty string if the option has no argument. The options occur in the list in
|
||||
the same order in which they were found, thus allowing multiple occurrences.
|
||||
Long and short options may be mixed.
|
||||
option list was stripped (this is a trailing slice of *args*). Each
|
||||
option-and-value pair returned has the option as its first element, prefixed
|
||||
with a hyphen for short options (e.g., ``'-x'``) or two hyphens for long
|
||||
options (e.g., ``'-``\ ``-long-option'``), and the option argument as its
|
||||
second element, or an empty string if the option has no argument. The
|
||||
options occur in the list in the same order in which they were found, thus
|
||||
allowing multiple occurrences. Long and short options may be mixed.
|
||||
|
||||
|
||||
.. function:: gnu_getopt(args, options[, long_options])
|
||||
@ -60,8 +60,8 @@ exception:
|
||||
non-option argument is encountered.
|
||||
|
||||
If the first character of the option string is '+', or if the environment
|
||||
variable POSIXLY_CORRECT is set, then option processing stops as soon as a non-
|
||||
option argument is encountered.
|
||||
variable POSIXLY_CORRECT is set, then option processing stops as soon as a
|
||||
non-option argument is encountered.
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
|
@ -385,10 +385,10 @@ initialize the "protected" :attr:`_charset` instance variable, defaulting to
|
||||
ids and message strings read from the catalog are converted to Unicode using
|
||||
this encoding. The :meth:`ugettext` method always returns a Unicode, while the
|
||||
:meth:`gettext` returns an encoded 8-bit string. For the message id arguments
|
||||
of both methods, either Unicode strings or 8-bit strings containing only US-
|
||||
ASCII characters are acceptable. Note that the Unicode version of the methods
|
||||
(i.e. :meth:`ugettext` and :meth:`ungettext`) are the recommended interface to
|
||||
use for internationalized Python programs.
|
||||
of both methods, either Unicode strings or 8-bit strings containing only
|
||||
US-ASCII characters are acceptable. Note that the Unicode version of the
|
||||
methods (i.e. :meth:`ugettext` and :meth:`ungettext`) are the recommended
|
||||
interface to use for internationalized Python programs.
|
||||
|
||||
The entire set of key/value pairs are placed into a dictionary and set as the
|
||||
"protected" :attr:`_info` instance variable.
|
||||
|
@ -100,8 +100,8 @@ The following exceptions are raised as appropriate:
|
||||
|
||||
.. exception:: InvalidURL
|
||||
|
||||
A subclass of :exc:`HTTPException`, raised if a port is given and is either non-
|
||||
numeric or empty.
|
||||
A subclass of :exc:`HTTPException`, raised if a port is given and is either
|
||||
non-numeric or empty.
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
@ -396,11 +396,11 @@ HTTPConnection Objects
|
||||
|
||||
This will send a request to the server using the HTTP request method *method*
|
||||
and the selector *url*. If the *body* argument is present, it should be a
|
||||
string of data to send after the headers are finished. Alternatively, it may be
|
||||
an open file object, in which case the contents of the file is sent; this file
|
||||
object should support ``fileno()`` and ``read()`` methods. The header Content-
|
||||
Length is automatically set to the correct value. The *headers* argument should
|
||||
be a mapping of extra HTTP headers to send with the request.
|
||||
string of data to send after the headers are finished. Alternatively, it may
|
||||
be an open file object, in which case the contents of the file is sent; this
|
||||
file object should support ``fileno()`` and ``read()`` methods. The header
|
||||
Content-Length is automatically set to the correct value. The *headers*
|
||||
argument should be a mapping of extra HTTP headers to send with the request.
|
||||
|
||||
.. versionchanged:: 2.6
|
||||
*body* can be a file object.
|
||||
|
@ -53,8 +53,8 @@ The module defines the following variables and functions:
|
||||
|
||||
.. function:: dither2mono(image, width, height)
|
||||
|
||||
Convert an 8-bit greyscale image to a 1-bit monochrome image using a (simple-
|
||||
minded) dithering algorithm.
|
||||
Convert an 8-bit greyscale image to a 1-bit monochrome image using a
|
||||
(simple-minded) dithering algorithm.
|
||||
|
||||
|
||||
.. function:: mono2grey(image, width, height, p0, p1)
|
||||
@ -93,11 +93,12 @@ The module defines the following variables and functions:
|
||||
|
||||
.. data:: backward_compatible
|
||||
|
||||
If set to 0, the functions in this module use a non-backward compatible way of
|
||||
representing multi-byte pixels on little-endian systems. The SGI for which this
|
||||
module was originally written is a big-endian system, so setting this variable
|
||||
will have no effect. However, the code wasn't originally intended to run on
|
||||
anything else, so it made assumptions about byte order which are not universal.
|
||||
Setting this variable to 0 will cause the byte order to be reversed on little-
|
||||
endian systems, so that it then is the same as on big-endian systems.
|
||||
If set to 0, the functions in this module use a non-backward compatible way
|
||||
of representing multi-byte pixels on little-endian systems. The SGI for
|
||||
which this module was originally written is a big-endian system, so setting
|
||||
this variable will have no effect. However, the code wasn't originally
|
||||
intended to run on anything else, so it made assumptions about byte order
|
||||
which are not universal. Setting this variable to 0 will cause the byte
|
||||
order to be reversed on little-endian systems, so that it then is the same as
|
||||
on big-endian systems.
|
||||
|
||||
|
@ -232,8 +232,8 @@ An :class:`IMAP4` instance has the following methods:
|
||||
|
||||
.. method:: IMAP4.getannotation(mailbox, entry, attribute)
|
||||
|
||||
Retrieve the specified ``ANNOTATION``\ s for *mailbox*. The method is non-
|
||||
standard, but is supported by the ``Cyrus`` server.
|
||||
Retrieve the specified ``ANNOTATION``\ s for *mailbox*. The method is
|
||||
non-standard, but is supported by the ``Cyrus`` server.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
|
@ -179,12 +179,12 @@ around for backward compatibility:
|
||||
|
||||
.. function:: init_frozen(name)
|
||||
|
||||
Initialize the frozen module called *name* and return its module object. If the
|
||||
module was already initialized, it will be initialized *again*. If there is no
|
||||
frozen module called *name*, ``None`` is returned. (Frozen modules are modules
|
||||
written in Python whose compiled byte-code object is incorporated into a custom-
|
||||
built Python interpreter by Python's :program:`freeze` utility. See
|
||||
:file:`Tools/freeze/` for now.)
|
||||
Initialize the frozen module called *name* and return its module object. If
|
||||
the module was already initialized, it will be initialized *again*. If there
|
||||
is no frozen module called *name*, ``None`` is returned. (Frozen modules are
|
||||
modules written in Python whose compiled byte-code object is incorporated
|
||||
into a custom-built Python interpreter by Python's :program:`freeze`
|
||||
utility. See :file:`Tools/freeze/` for now.)
|
||||
|
||||
|
||||
.. function:: is_builtin(name)
|
||||
@ -242,10 +242,10 @@ around for backward compatibility:
|
||||
|
||||
.. class:: NullImporter(path_string)
|
||||
|
||||
The :class:`NullImporter` type is a :pep:`302` import hook that handles non-
|
||||
directory path strings by failing to find any modules. Calling this type with
|
||||
an existing directory or empty string raises :exc:`ImportError`. Otherwise, a
|
||||
:class:`NullImporter` instance is returned.
|
||||
The :class:`NullImporter` type is a :pep:`302` import hook that handles
|
||||
non-directory path strings by failing to find any modules. Calling this type
|
||||
with an existing directory or empty string raises :exc:`ImportError`.
|
||||
Otherwise, a :class:`NullImporter` instance is returned.
|
||||
|
||||
Python adds instances of this type to ``sys.path_importer_cache`` for any path
|
||||
entries that are not directories and are not handled by any other path hooks on
|
||||
|
@ -202,12 +202,12 @@ Note:
|
||||
identified by *path* if it is a module, or ``None`` if it would not be
|
||||
identified as a module. The return tuple is ``(name, suffix, mode, mtype)``,
|
||||
where *name* is the name of the module without the name of any enclosing
|
||||
package, *suffix* is the trailing part of the file name (which may not be a dot-
|
||||
delimited extension), *mode* is the :func:`open` mode that would be used
|
||||
(``'r'`` or ``'rb'``), and *mtype* is an integer giving the type of the module.
|
||||
*mtype* will have a value which can be compared to the constants defined in the
|
||||
:mod:`imp` module; see the documentation for that module for more information on
|
||||
module types.
|
||||
package, *suffix* is the trailing part of the file name (which may not be a
|
||||
dot-delimited extension), *mode* is the :func:`open` mode that would be used
|
||||
(``'r'`` or ``'rb'``), and *mtype* is an integer giving the type of the
|
||||
module. *mtype* will have a value which can be compared to the constants
|
||||
defined in the :mod:`imp` module; see the documentation for that module for
|
||||
more information on module types.
|
||||
|
||||
|
||||
.. function:: getmodulename(path)
|
||||
|
@ -279,16 +279,16 @@ loops that truncate the stream.
|
||||
last tuple can be pre-padded with fill values using ``izip(*[chain(s,
|
||||
[None]*(n-1))]*n)``.
|
||||
|
||||
Note, when :func:`izip` is used with unequal length inputs, subsequent iteration
|
||||
over the longer iterables cannot reliably be continued after :func:`izip`
|
||||
terminates. Potentially, up to one entry will be missing from each of the left-
|
||||
over iterables. This occurs because a value is fetched from each iterator in-
|
||||
turn, but the process ends when one of the iterators terminates. This leaves
|
||||
the last fetched values in limbo (they cannot be returned in a final, incomplete
|
||||
tuple and they are cannot be pushed back into the iterator for retrieval with
|
||||
``it.next()``). In general, :func:`izip` should only be used with unequal
|
||||
length inputs when you don't care about trailing, unmatched values from the
|
||||
longer iterables.
|
||||
Note, when :func:`izip` is used with unequal length inputs, subsequent
|
||||
iteration over the longer iterables cannot reliably be continued after
|
||||
:func:`izip` terminates. Potentially, up to one entry will be missing from
|
||||
each of the left-over iterables. This occurs because a value is fetched from
|
||||
each iterator in turn, but the process ends when one of the iterators
|
||||
terminates. This leaves the last fetched values in limbo (they cannot be
|
||||
returned in a final, incomplete tuple and they are cannot be pushed back into
|
||||
the iterator for retrieval with ``it.next()``). In general, :func:`izip`
|
||||
should only be used with unequal length inputs when you don't care about
|
||||
trailing, unmatched values from the longer iterables.
|
||||
|
||||
|
||||
.. function:: izip_longest(*iterables[, fillvalue])
|
||||
|
@ -984,9 +984,9 @@ StreamHandler
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
The :class:`StreamHandler` class, located in the core :mod:`logging` package,
|
||||
sends logging output to streams such as *sys.stdout*, *sys.stderr* or any file-
|
||||
like object (or, more precisely, any object which supports :meth:`write` and
|
||||
:meth:`flush` methods).
|
||||
sends logging output to streams such as *sys.stdout*, *sys.stderr* or any
|
||||
file-like object (or, more precisely, any object which supports :meth:`write`
|
||||
and :meth:`flush` methods).
|
||||
|
||||
|
||||
.. class:: StreamHandler([strm])
|
||||
@ -1635,8 +1635,8 @@ made, and any exception information to be logged.
|
||||
|
||||
.. method:: LogRecord.getMessage()
|
||||
|
||||
Returns the message for this :class:`LogRecord` instance after merging any user-
|
||||
supplied arguments with the message.
|
||||
Returns the message for this :class:`LogRecord` instance after merging any
|
||||
user-supplied arguments with the message.
|
||||
|
||||
|
||||
Thread Safety
|
||||
|
@ -617,12 +617,13 @@ of a message is indicated by the start of the next message or, in the case of
|
||||
the last message, a line containing a Control-Underscore (``'\\037'``)
|
||||
character.
|
||||
|
||||
Messages in a Babyl mailbox have two sets of headers, original headers and so-
|
||||
called visible headers. Visible headers are typically a subset of the original
|
||||
headers that have been reformatted or abridged to be more attractive. Each
|
||||
message in a Babyl mailbox also has an accompanying list of :dfn:`labels`, or
|
||||
short strings that record extra information about the message, and a list of all
|
||||
user-defined labels found in the mailbox is kept in the Babyl options section.
|
||||
Messages in a Babyl mailbox have two sets of headers, original headers and
|
||||
so-called visible headers. Visible headers are typically a subset of the
|
||||
original headers that have been reformatted or abridged to be more
|
||||
attractive. Each message in a Babyl mailbox also has an accompanying list of
|
||||
:dfn:`labels`, or short strings that record extra information about the message,
|
||||
and a list of all user-defined labels found in the mailbox is kept in the Babyl
|
||||
options section.
|
||||
|
||||
:class:`Babyl` instances have all of the methods of :class:`Mailbox` in addition
|
||||
to the following:
|
||||
@ -772,8 +773,8 @@ whether or not they've actually been read. Each message in :file:`cur` has an
|
||||
"info" section added to its file name to store information about its state.
|
||||
(Some mail readers may also add an "info" section to messages in :file:`new`.)
|
||||
The "info" section may take one of two forms: it may contain "2," followed by a
|
||||
list of standardized flags (e.g., "2,FR") or it may contain "1," followed by so-
|
||||
called experimental information. Standard flags for Maildir messages are as
|
||||
list of standardized flags (e.g., "2,FR") or it may contain "1," followed by
|
||||
so-called experimental information. Standard flags for Maildir messages are as
|
||||
follows:
|
||||
|
||||
+------+---------+--------------------------------+
|
||||
@ -1540,9 +1541,9 @@ counterparts are as follows:
|
||||
:class:`UnixMailbox` except that individual messages are separated by only
|
||||
``From`` lines.
|
||||
|
||||
For more information, see `Configuring Netscape Mail on Unix: Why the Content-
|
||||
Length Format is Bad <http://home.netscape.com/eng/mozilla/2.0/relnotes/demo
|
||||
/content-length.html>`_.
|
||||
For more information, see `Configuring Netscape Mail on Unix: Why the
|
||||
Content-Length Format is Bad
|
||||
<http://home.netscape.com/eng/mozilla/2.0/relnotes/demo/content-length.html>`_.
|
||||
|
||||
|
||||
.. class:: PortableUnixMailbox(fp[, factory])
|
||||
|
@ -209,15 +209,15 @@ The module also defines two mathematical constants:
|
||||
.. note::
|
||||
|
||||
The :mod:`math` module consists mostly of thin wrappers around the platform C
|
||||
math library functions. Behavior in exceptional cases is loosely specified by
|
||||
the C standards, and Python inherits much of its math-function error-reporting
|
||||
behavior from the platform C implementation. As a result, the specific
|
||||
exceptions raised in error cases (and even whether some arguments are considered
|
||||
to be exceptional at all) are not defined in any useful cross-platform or cross-
|
||||
release way. For example, whether ``math.log(0)`` returns ``-Inf`` or raises
|
||||
:exc:`ValueError` or :exc:`OverflowError` isn't defined, and in cases where
|
||||
``math.log(0)`` raises :exc:`OverflowError`, ``math.log(0L)`` may raise
|
||||
:exc:`ValueError` instead.
|
||||
math library functions. Behavior in exceptional cases is loosely specified
|
||||
by the C standards, and Python inherits much of its math-function
|
||||
error-reporting behavior from the platform C implementation. As a result,
|
||||
the specific exceptions raised in error cases (and even whether some
|
||||
arguments are considered to be exceptional at all) are not defined in any
|
||||
useful cross-platform or cross-release way. For example, whether
|
||||
``math.log(0)`` returns ``-Inf`` or raises :exc:`ValueError` or
|
||||
:exc:`OverflowError` isn't defined, and in cases where ``math.log(0)`` raises
|
||||
:exc:`OverflowError`, ``math.log(0L)`` may raise :exc:`ValueError` instead.
|
||||
|
||||
|
||||
.. seealso::
|
||||
|
@ -39,11 +39,12 @@ the information :func:`init` sets up.
|
||||
Encoding suffixes are case sensitive; type suffixes are first tried case
|
||||
sensitively, then case insensitively.
|
||||
|
||||
Optional *strict* is a flag specifying whether the list of known MIME types is
|
||||
limited to only the official types `registered with IANA <http://www.isi.edu/in-
|
||||
notes/iana/assignments/media-types>`_ are recognized. When *strict* is true
|
||||
(the default), only the IANA types are supported; when *strict* is false, some
|
||||
additional non-standard but commonly used MIME types are also recognized.
|
||||
Optional *strict* is a flag specifying whether the list of known MIME types
|
||||
is limited to only the official types `registered with IANA
|
||||
<http://www.isi.edu/in-notes/iana/assignments/media-types>`_ are recognized.
|
||||
When *strict* is true (the default), only the IANA types are supported; when
|
||||
*strict* is false, some additional non-standard but commonly used MIME types
|
||||
are also recognized.
|
||||
|
||||
|
||||
.. function:: guess_all_extensions(type[, strict])
|
||||
|
@ -11,8 +11,8 @@
|
||||
module. This module is present only to maintain backward compatibility.
|
||||
|
||||
The :mod:`mimify` module defines two functions to convert mail messages to and
|
||||
from MIME format. The mail message can be either a simple message or a so-
|
||||
called multipart message. Each part is treated separately. Mimifying (a part
|
||||
from MIME format. The mail message can be either a simple message or a
|
||||
so-called multipart message. Each part is treated separately. Mimifying (a part
|
||||
of) a message entails encoding the message as quoted-printable if it contains
|
||||
any characters that cannot be represented using 7-bit ASCII. Unmimifying (a
|
||||
part of) a message entails undoing the quoted-printable encoding. Mimify and
|
||||
@ -61,9 +61,9 @@ variables:
|
||||
|
||||
.. data:: MAXLEN
|
||||
|
||||
By default, a part will be encoded as quoted-printable when it contains any non-
|
||||
ASCII characters (characters with the 8th bit set), or if there are any lines
|
||||
longer than :const:`MAXLEN` characters (default value 200).
|
||||
By default, a part will be encoded as quoted-printable when it contains any
|
||||
non-ASCII characters (characters with the 8th bit set), or if there are any
|
||||
lines longer than :const:`MAXLEN` characters (default value 200).
|
||||
|
||||
|
||||
.. data:: CHARSET
|
||||
|
@ -147,8 +147,8 @@ Memory-mapped file objects support the following methods:
|
||||
|
||||
.. method:: mmap.size()
|
||||
|
||||
Return the length of the file, which can be larger than the size of the memory-
|
||||
mapped area.
|
||||
Return the length of the file, which can be larger than the size of the
|
||||
memory-mapped area.
|
||||
|
||||
|
||||
.. method:: mmap.tell()
|
||||
|
@ -424,7 +424,7 @@ to create MSI files with a user-interface for installing Python packages.
|
||||
belongs to, and *name* is the control's name.
|
||||
|
||||
|
||||
.. method:: Control.event(event, argument[, condition = ``1''[, ordering]])
|
||||
.. method:: Control.event(event, argument[, condition=1[, ordering]])
|
||||
|
||||
Make an entry into the ``ControlEvent`` table for this control.
|
||||
|
||||
|
@ -33,8 +33,8 @@ overriding methods it can be easily adapted for more general use.
|
||||
It will be useful to know that in :class:`MultiFile`'s view of the world, text
|
||||
is composed of three kinds of lines: data, section-dividers, and end-markers.
|
||||
MultiFile is designed to support parsing of messages that may have multiple
|
||||
nested message parts, each with its own pattern for section-divider and end-
|
||||
marker lines.
|
||||
nested message parts, each with its own pattern for section-divider and
|
||||
end-marker lines.
|
||||
|
||||
|
||||
.. seealso::
|
||||
@ -110,9 +110,9 @@ A :class:`MultiFile` instance has the following methods:
|
||||
return the empty string to indicate end-of-file, until a call to :meth:`pop`
|
||||
removes the boundary a or :meth:`next` call reenables it.
|
||||
|
||||
It is possible to push more than one boundary. Encountering the most-recently-
|
||||
pushed boundary will return EOF; encountering any other boundary will raise an
|
||||
error.
|
||||
It is possible to push more than one boundary. Encountering the
|
||||
most-recently-pushed boundary will return EOF; encountering any other
|
||||
boundary will raise an error.
|
||||
|
||||
|
||||
.. method:: MultiFile.pop()
|
||||
@ -122,19 +122,19 @@ A :class:`MultiFile` instance has the following methods:
|
||||
|
||||
.. method:: MultiFile.section_divider(str)
|
||||
|
||||
Turn a boundary into a section-divider line. By default, this method prepends
|
||||
``'-``\ ``-'`` (which MIME section boundaries have) but it is declared so it can
|
||||
be overridden in derived classes. This method need not append LF or CR-LF, as
|
||||
comparison with the result ignores trailing whitespace.
|
||||
Turn a boundary into a section-divider line. By default, this method
|
||||
prepends ``'--'`` (which MIME section boundaries have) but it is declared so
|
||||
it can be overridden in derived classes. This method need not append LF or
|
||||
CR-LF, as comparison with the result ignores trailing whitespace.
|
||||
|
||||
|
||||
.. method:: MultiFile.end_marker(str)
|
||||
|
||||
Turn a boundary string into an end-marker line. By default, this method
|
||||
prepends ``'-``\ ``-'`` and appends ``'-``\ ``-'`` (like a MIME-multipart end-
|
||||
of-message marker) but it is declared so it can be overridden in derived
|
||||
classes. This method need not append LF or CR-LF, as comparison with the result
|
||||
ignores trailing whitespace.
|
||||
prepends ``'--'`` and appends ``'--'`` (like a MIME-multipart end-of-message
|
||||
marker) but it is declared so it can be overridden in derived classes. This
|
||||
method need not append LF or CR-LF, as comparison with the result ignores
|
||||
trailing whitespace.
|
||||
|
||||
Finally, :class:`MultiFile` instances have two public instance variables:
|
||||
|
||||
|
@ -70,9 +70,9 @@ Instances of :class:`netrc` have public instance variables:
|
||||
|
||||
.. note::
|
||||
|
||||
Passwords are limited to a subset of the ASCII character set. Versions of this
|
||||
module prior to 2.3 were extremely limited. Starting with 2.3, all ASCII
|
||||
punctuation is allowed in passwords. However, note that whitespace and non-
|
||||
printable characters are not allowed in passwords. This is a limitation of the
|
||||
way the .netrc file is parsed and may be removed in the future.
|
||||
Passwords are limited to a subset of the ASCII character set. Versions of
|
||||
this module prior to 2.3 were extremely limited. Starting with 2.3, all
|
||||
ASCII punctuation is allowed in passwords. However, note that whitespace and
|
||||
non-printable characters are not allowed in passwords. This is a limitation
|
||||
of the way the .netrc file is parsed and may be removed in the future.
|
||||
|
||||
|
@ -11,8 +11,8 @@ The :mod:`new` module allows an interface to the interpreter object creation
|
||||
functions. This is for use primarily in marshal-type functions, when a new
|
||||
object needs to be created "magically" and not by using the regular creation
|
||||
functions. This module provides a low-level interface to the interpreter, so
|
||||
care must be exercised when using this module. It is possible to supply non-
|
||||
sensical arguments which crash the interpreter when the object is used.
|
||||
care must be exercised when using this module. It is possible to supply
|
||||
non-sensical arguments which crash the interpreter when the object is used.
|
||||
|
||||
The :mod:`new` module defines the following functions:
|
||||
|
||||
|
@ -53,18 +53,18 @@ The module itself defines the following items:
|
||||
|
||||
.. class:: NNTP(host[, port [, user[, password [, readermode] [, usenetrc]]]])
|
||||
|
||||
Return a new instance of the :class:`NNTP` class, representing a connection to
|
||||
the NNTP server running on host *host*, listening at port *port*. The default
|
||||
*port* is 119. If the optional *user* and *password* are provided, or if
|
||||
suitable credentials are present in :file:`/.netrc` and the optional flag
|
||||
*usenetrc* is true (the default), the ``AUTHINFO USER`` and ``AUTHINFO PASS``
|
||||
commands are used to identify and authenticate the user to the server. If the
|
||||
optional flag *readermode* is true, then a ``mode reader`` command is sent
|
||||
before authentication is performed. Reader mode is sometimes necessary if you
|
||||
are connecting to an NNTP server on the local machine and intend to call reader-
|
||||
specific commands, such as ``group``. If you get unexpected
|
||||
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*. *readermode*
|
||||
defaults to ``None``. *usenetrc* defaults to ``True``.
|
||||
Return a new instance of the :class:`NNTP` class, representing a connection
|
||||
to the NNTP server running on host *host*, listening at port *port*. The
|
||||
default *port* is 119. If the optional *user* and *password* are provided,
|
||||
or if suitable credentials are present in :file:`/.netrc` and the optional
|
||||
flag *usenetrc* is true (the default), the ``AUTHINFO USER`` and ``AUTHINFO
|
||||
PASS`` commands are used to identify and authenticate the user to the server.
|
||||
If the optional flag *readermode* is true, then a ``mode reader`` command is
|
||||
sent before authentication is performed. Reader mode is sometimes necessary
|
||||
if you are connecting to an NNTP server on the local machine and intend to
|
||||
call reader-specific commands, such as ``group``. If you get unexpected
|
||||
:exc:`NNTPPermanentError`\ s, you might need to set *readermode*.
|
||||
*readermode* defaults to ``None``. *usenetrc* defaults to ``True``.
|
||||
|
||||
.. versionchanged:: 2.4
|
||||
*usenetrc* argument added.
|
||||
|
@ -117,18 +117,18 @@ option
|
||||
|
||||
Some other option syntaxes that the world has seen include:
|
||||
|
||||
* a hyphen followed by a few letters, e.g. ``"-pf"`` (this is *not* the same
|
||||
as multiple options merged into a single argument)
|
||||
* a hyphen followed by a few letters, e.g. ``"-pf"`` (this is *not* the same
|
||||
as multiple options merged into a single argument)
|
||||
|
||||
* a hyphen followed by a whole word, e.g. ``"-file"`` (this is technically
|
||||
equivalent to the previous syntax, but they aren't usually seen in the same
|
||||
program)
|
||||
* a hyphen followed by a whole word, e.g. ``"-file"`` (this is technically
|
||||
equivalent to the previous syntax, but they aren't usually seen in the same
|
||||
program)
|
||||
|
||||
* a plus sign followed by a single letter, or a few letters, or a word, e.g.
|
||||
``"+f"``, ``"+rgb"``
|
||||
* a plus sign followed by a single letter, or a few letters, or a word, e.g.
|
||||
``"+f"``, ``"+rgb"``
|
||||
|
||||
* a slash followed by a letter, or a few letters, or a word, e.g. ``"/f"``,
|
||||
``"/file"``
|
||||
* a slash followed by a letter, or a few letters, or a word, e.g. ``"/f"``,
|
||||
``"/file"``
|
||||
|
||||
These option syntaxes are not supported by :mod:`optparse`, and they never will
|
||||
be. This is deliberate: the first three are non-standard on any environment,
|
||||
@ -470,8 +470,8 @@ Generating help
|
||||
:mod:`optparse`'s ability to generate help and usage text automatically is
|
||||
useful for creating user-friendly command-line interfaces. All you have to do
|
||||
is supply a :attr:`help` value for each option, and optionally a short usage
|
||||
message for your whole program. Here's an OptionParser populated with user-
|
||||
friendly (documented) options::
|
||||
message for your whole program. Here's an OptionParser populated with
|
||||
user-friendly (documented) options::
|
||||
|
||||
usage = "usage: %prog [options] arg1 arg2"
|
||||
parser = OptionParser(usage=usage)
|
||||
@ -488,9 +488,9 @@ friendly (documented) options::
|
||||
help="interaction mode: novice, intermediate, "
|
||||
"or expert [default: %default]")
|
||||
|
||||
If :mod:`optparse` encounters either ``"-h"`` or ``"--help"`` on the command-
|
||||
line, or if you just call :meth:`parser.print_help`, it prints the following to
|
||||
standard output::
|
||||
If :mod:`optparse` encounters either ``"-h"`` or ``"--help"`` on the
|
||||
command-line, or if you just call :meth:`parser.print_help`, it prints the
|
||||
following to standard output::
|
||||
|
||||
usage: <yourscript> [options] arg1 arg2
|
||||
|
||||
@ -521,12 +521,12 @@ help message:
|
||||
default: ``"usage: %prog [options]"``, which is fine if your script doesn't take
|
||||
any positional arguments.
|
||||
|
||||
* every option defines a help string, and doesn't worry about line-
|
||||
wrapping---\ :mod:`optparse` takes care of wrapping lines and making the help
|
||||
output look good.
|
||||
* every option defines a help string, and doesn't worry about line-wrapping---
|
||||
:mod:`optparse` takes care of wrapping lines and making the help output look
|
||||
good.
|
||||
|
||||
* options that take a value indicate this fact in their automatically-
|
||||
generated help message, e.g. for the "mode" option::
|
||||
* options that take a value indicate this fact in their automatically-generated
|
||||
help message, e.g. for the "mode" option::
|
||||
|
||||
-m MODE, --mode=MODE
|
||||
|
||||
@ -1663,14 +1663,14 @@ functions. A type-checking function has the following signature::
|
||||
where ``option`` is an :class:`Option` instance, ``opt`` is an option string
|
||||
(e.g., ``"-f"``), and ``value`` is the string from the command line that must be
|
||||
checked and converted to your desired type. ``check_mytype()`` should return an
|
||||
object of the hypothetical type ``mytype``. The value returned by a type-
|
||||
checking function will wind up in the OptionValues instance returned by
|
||||
object of the hypothetical type ``mytype``. The value returned by a
|
||||
type-checking function will wind up in the OptionValues instance returned by
|
||||
:meth:`OptionParser.parse_args`, or be passed to a callback as the ``value``
|
||||
parameter.
|
||||
|
||||
Your type-checking function should raise OptionValueError if it encounters any
|
||||
problems. OptionValueError takes a single string argument, which is passed as-
|
||||
is to OptionParser's :meth:`error` method, which in turn prepends the program
|
||||
problems. OptionValueError takes a single string argument, which is passed
|
||||
as-is to OptionParser's :meth:`error` method, which in turn prepends the program
|
||||
name and the string ``"error:"`` and prints everything to stderr before
|
||||
terminating the process.
|
||||
|
||||
|
@ -644,9 +644,9 @@ by file descriptors.
|
||||
|
||||
.. function:: ttyname(fd)
|
||||
|
||||
Return a string which specifies the terminal device associated with file-
|
||||
descriptor *fd*. If *fd* is not associated with a terminal device, an exception
|
||||
is raised. Availability:Macintosh, Unix.
|
||||
Return a string which specifies the terminal device associated with
|
||||
file-descriptor *fd*. If *fd* is not associated with a terminal device, an
|
||||
exception is raised. Availability:Macintosh, Unix.
|
||||
|
||||
|
||||
.. function:: write(fd, str)
|
||||
@ -676,8 +676,8 @@ platforms. For descriptions of their availability and use, consult
|
||||
O_EXCL
|
||||
O_TRUNC
|
||||
|
||||
Options for the *flag* argument to the :func:`open` function. These can be bit-
|
||||
wise OR'd together. Availability: Macintosh, Unix, Windows.
|
||||
Options for the *flag* argument to the :func:`open` function. These can be
|
||||
bit-wise OR'd together. Availability: Macintosh, Unix, Windows.
|
||||
|
||||
|
||||
.. data:: O_DSYNC
|
||||
@ -695,8 +695,8 @@ platforms. For descriptions of their availability and use, consult
|
||||
|
||||
.. data:: O_BINARY
|
||||
|
||||
Option for the *flag* argument to the :func:`open` function. This can be bit-
|
||||
wise OR'd together with those listed above. Availability: Windows.
|
||||
Option for the *flag* argument to the :func:`open` function. This can be
|
||||
bit-wise OR'd together with those listed above. Availability: Windows.
|
||||
|
||||
.. % XXX need to check on the availability of this one.
|
||||
|
||||
@ -708,8 +708,8 @@ platforms. For descriptions of their availability and use, consult
|
||||
O_SEQUENTIAL
|
||||
O_TEXT
|
||||
|
||||
Options for the *flag* argument to the :func:`open` function. These can be bit-
|
||||
wise OR'd together. Availability: Windows.
|
||||
Options for the *flag* argument to the :func:`open` function. These can be
|
||||
bit-wise OR'd together. Availability: Windows.
|
||||
|
||||
|
||||
.. data:: SEEK_SET
|
||||
@ -813,25 +813,16 @@ Files and Directories
|
||||
Set the flags of *path* to the numeric *flags*. *flags* may take a combination
|
||||
(bitwise OR) of the following values (as defined in the :mod:`stat` module):
|
||||
|
||||
* ``UF_NODUMP``
|
||||
|
||||
* ``UF_IMMUTABLE``
|
||||
|
||||
* ``UF_APPEND``
|
||||
|
||||
* ``UF_OPAQUE``
|
||||
|
||||
* ``UF_NOUNLINK``
|
||||
|
||||
* ``SF_ARCHIVED``
|
||||
|
||||
* ``SF_IMMUTABLE``
|
||||
|
||||
* ``SF_APPEND``
|
||||
|
||||
* ``SF_NOUNLINK``
|
||||
|
||||
* ``SF_SNAPSHOT``
|
||||
* ``UF_NODUMP``
|
||||
* ``UF_IMMUTABLE``
|
||||
* ``UF_APPEND``
|
||||
* ``UF_OPAQUE``
|
||||
* ``UF_NOUNLINK``
|
||||
* ``SF_ARCHIVED``
|
||||
* ``SF_IMMUTABLE``
|
||||
* ``SF_APPEND``
|
||||
* ``SF_NOUNLINK``
|
||||
* ``SF_SNAPSHOT``
|
||||
|
||||
Availability: Macintosh, Unix.
|
||||
|
||||
@ -852,43 +843,26 @@ Files and Directories
|
||||
following values (as defined in the :mod:`stat` module) or bitwise or-ed
|
||||
combinations of them:
|
||||
|
||||
* ``stat.S_ISUID``
|
||||
|
||||
* ``stat.S_ISGID``
|
||||
|
||||
* ``stat.S_ENFMT``
|
||||
|
||||
* ``stat.S_ISVTX``
|
||||
|
||||
* ``stat.S_IREAD``
|
||||
|
||||
* ``stat.S_IWRITE``
|
||||
|
||||
* ``stat.S_IEXEC``
|
||||
|
||||
* ``stat.S_IRWXU``
|
||||
|
||||
* ``stat.S_IRUSR``
|
||||
|
||||
* ``stat.S_IWUSR``
|
||||
|
||||
* ``stat.S_IXUSR``
|
||||
|
||||
* ``stat.S_IRWXG``
|
||||
|
||||
* ``stat.S_IRGRP``
|
||||
|
||||
* ``stat.S_IWGRP``
|
||||
|
||||
* ``stat.S_IXGRP``
|
||||
|
||||
* ``stat.S_IRWXO``
|
||||
|
||||
* ``stat.S_IROTH``
|
||||
|
||||
* ``stat.S_IWOTH``
|
||||
|
||||
* ``stat.S_IXOTH``
|
||||
* ``stat.S_ISUID``
|
||||
* ``stat.S_ISGID``
|
||||
* ``stat.S_ENFMT``
|
||||
* ``stat.S_ISVTX``
|
||||
* ``stat.S_IREAD``
|
||||
* ``stat.S_IWRITE``
|
||||
* ``stat.S_IEXEC``
|
||||
* ``stat.S_IRWXU``
|
||||
* ``stat.S_IRUSR``
|
||||
* ``stat.S_IWUSR``
|
||||
* ``stat.S_IXUSR``
|
||||
* ``stat.S_IRWXG``
|
||||
* ``stat.S_IRGRP``
|
||||
* ``stat.S_IWGRP``
|
||||
* ``stat.S_IXGRP``
|
||||
* ``stat.S_IRWXO``
|
||||
* ``stat.S_IROTH``
|
||||
* ``stat.S_IWOTH``
|
||||
* ``stat.S_IXOTH``
|
||||
|
||||
Availability: Macintosh, Unix, Windows.
|
||||
|
||||
@ -1317,7 +1291,7 @@ Files and Directories
|
||||
Availability: Macintosh, Unix, Windows.
|
||||
|
||||
|
||||
.. function:: walk(top[, topdown\ ``=True`` [, onerror\ ``=None``[, followlinks\ ``=False``]]])
|
||||
.. function:: walk(top[, topdown=True [, onerror=None[, followlinks=False]]])
|
||||
|
||||
.. index::
|
||||
single: directory; walking
|
||||
|
@ -78,11 +78,12 @@ the standard audio interface for Linux and recent versions of FreeBSD.
|
||||
module first looks in the environment variable :envvar:`AUDIODEV` for a device
|
||||
to use. If not found, it falls back to :file:`/dev/dsp`.
|
||||
|
||||
*mode* is one of ``'r'`` for read-only (record) access, ``'w'`` for write-only
|
||||
(playback) access and ``'rw'`` for both. Since many sound cards only allow one
|
||||
process to have the recorder or player open at a time, it is a good idea to open
|
||||
the device only for the activity needed. Further, some sound cards are half-
|
||||
duplex: they can be opened for reading or writing, but not both at once.
|
||||
*mode* is one of ``'r'`` for read-only (record) access, ``'w'`` for
|
||||
write-only (playback) access and ``'rw'`` for both. Since many sound cards
|
||||
only allow one process to have the recorder or player open at a time, it is a
|
||||
good idea to open the device only for the activity needed. Further, some
|
||||
sound cards are half-duplex: they can be opened for reading or writing, but
|
||||
not both at once.
|
||||
|
||||
Note the unusual calling syntax: the *first* argument is optional, and the
|
||||
second is required. This is a historical artifact for compatibility with the
|
||||
|
@ -61,18 +61,18 @@ also available for Python:
|
||||
Summerfield.
|
||||
|
||||
`wxPython <http://www.wxpython.org>`_
|
||||
wxPython is a cross-platform GUI toolkit for Python that is built around the
|
||||
popular `wxWidgets <http://www.wxwidgets.org/>`_ (formerly
|
||||
wxWindows) C++ toolkit. It provides a
|
||||
native look and feel for applications on Windows, Mac OS X, and Unix systems by
|
||||
using each platform's native widgets where ever possible, (GTK+ on Unix-like
|
||||
systems). In addition to an extensive set of widgets, wxPython provides classes
|
||||
for online documentation and context sensitive help, printing, HTML viewing,
|
||||
low-level device context drawing, drag and drop, system clipboard access, an
|
||||
XML-based resource format and more, including an ever growing library of user-
|
||||
contributed modules. wxPython has a book,
|
||||
`wxPython in Action <http://www.amazon.com/exec/obidos/ASIN/1932394621>`_,
|
||||
by Noel Rappin and Robin Dunn.
|
||||
wxPython is a cross-platform GUI toolkit for Python that is built around
|
||||
the popular `wxWidgets <http://www.wxwidgets.org/>`_ (formerly wxWindows)
|
||||
C++ toolkit. It provides a native look and feel for applications on
|
||||
Windows, Mac OS X, and Unix systems by using each platform's native
|
||||
widgets where ever possible, (GTK+ on Unix-like systems). In addition to
|
||||
an extensive set of widgets, wxPython provides classes for online
|
||||
documentation and context sensitive help, printing, HTML viewing,
|
||||
low-level device context drawing, drag and drop, system clipboard access,
|
||||
an XML-based resource format and more, including an ever growing library
|
||||
of user-contributed modules. wxPython has a book, `wxPython in Action
|
||||
<http://www.amazon.com/exec/obidos/ASIN/1932394621>`_, by Noel Rappin and
|
||||
Robin Dunn.
|
||||
|
||||
PyGTK, PyQt, and wxPython, all have a modern look and feel and far more
|
||||
widgets and better documentation than Tkinter. In addition,
|
||||
|
@ -189,7 +189,7 @@ numbering information.
|
||||
information is omitted if the flag is false or omitted.
|
||||
|
||||
|
||||
.. function:: compileast(ast[, filename\ ``= '<ast>'``])
|
||||
.. function:: compileast(ast[, filename='<ast>'])
|
||||
|
||||
.. index:: builtin: eval
|
||||
|
||||
|
@ -91,8 +91,8 @@ object into a byte stream and it can transform the byte stream into an object
|
||||
with the same internal structure. Perhaps the most obvious thing to do with
|
||||
these byte streams is to write them onto a file, but it is also conceivable to
|
||||
send them across a network or store them in a database. The module
|
||||
:mod:`shelve` provides a simple interface to pickle and unpickle objects on DBM-
|
||||
style database files.
|
||||
:mod:`shelve` provides a simple interface to pickle and unpickle objects on
|
||||
DBM-style database files.
|
||||
|
||||
|
||||
Data stream format
|
||||
@ -689,9 +689,9 @@ that a self-referencing list is pickled and restored correctly. ::
|
||||
|
||||
output.close()
|
||||
|
||||
The following example reads the resulting pickled data. When reading a pickle-
|
||||
containing file, you should open the file in binary mode because you can't be
|
||||
sure if the ASCII or binary format was used. ::
|
||||
The following example reads the resulting pickled data. When reading a
|
||||
pickle-containing file, you should open the file in binary mode because you
|
||||
can't be sure if the ASCII or binary format was used. ::
|
||||
|
||||
import pprint, pickle
|
||||
|
||||
|
@ -295,13 +295,13 @@ reading the source code for these modules.
|
||||
|
||||
.. function:: run(command[, filename])
|
||||
|
||||
This function takes a single argument that can be passed to the :keyword:`exec`
|
||||
statement, and an optional file name. In all cases this routine attempts to
|
||||
:keyword:`exec` its first argument, and gather profiling statistics from the
|
||||
execution. If no file name is present, then this function automatically prints a
|
||||
simple profiling report, sorted by the standard name string (file/line/function-
|
||||
name) that is presented in each line. The following is a typical output from
|
||||
such a call::
|
||||
This function takes a single argument that can be passed to the
|
||||
:keyword:`exec` statement, and an optional file name. In all cases this
|
||||
routine attempts to :keyword:`exec` its first argument, and gather profiling
|
||||
statistics from the execution. If no file name is present, then this function
|
||||
automatically prints a simple profiling report, sorted by the standard name
|
||||
string (file/line/function-name) that is presented in each line. The
|
||||
following is a typical output from such a call::
|
||||
|
||||
2706 function calls (2004 primitive calls) in 4.504 CPU seconds
|
||||
|
||||
@ -527,12 +527,12 @@ The :class:`Stats` Class
|
||||
argument is also identical. Each caller is reported on its own line. The
|
||||
format differs slightly depending on the profiler that produced the stats:
|
||||
|
||||
* With :mod:`profile`, a number is shown in parentheses after each caller to
|
||||
show how many times this specific call was made. For convenience, a second non-
|
||||
parenthesized number repeats the cumulative time spent in the function at the
|
||||
right.
|
||||
* With :mod:`profile`, a number is shown in parentheses after each caller to
|
||||
show how many times this specific call was made. For convenience, a second
|
||||
non-parenthesized number repeats the cumulative time spent in the function
|
||||
at the right.
|
||||
|
||||
* With :mod:`cProfile`, each caller is preceeded by three numbers: the number of
|
||||
* With :mod:`cProfile`, each caller is preceeded by three numbers: the number of
|
||||
times this specific call was made, and the total and cumulative times spent in
|
||||
the current function while it was invoked by this specific caller.
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
.. index:: single: Expat
|
||||
|
||||
The :mod:`xml.parsers.expat` module is a Python interface to the Expat non-
|
||||
validating XML parser. The module provides a single extension type,
|
||||
The :mod:`xml.parsers.expat` module is a Python interface to the Expat
|
||||
non-validating XML parser. The module provides a single extension type,
|
||||
:class:`xmlparser`, that represents the current state of an XML parser. After
|
||||
an :class:`xmlparser` object has been created, various attributes of the object
|
||||
can be set to handler functions. When an XML document is then fed to the
|
||||
|
@ -10,8 +10,8 @@ This module implements pseudo-random number generators for various
|
||||
distributions.
|
||||
|
||||
For integers, uniform selection from a range. For sequences, uniform selection
|
||||
of a random element, a function to generate a random permutation of a list in-
|
||||
place, and a function for random sampling without replacement.
|
||||
of a random element, a function to generate a random permutation of a list
|
||||
in-place, and a function for random sampling without replacement.
|
||||
|
||||
On the real line, there are functions to compute uniform, normal (Gaussian),
|
||||
lognormal, negative exponential, gamma, and beta distributions. For generating
|
||||
|
@ -134,10 +134,10 @@ The special characters are:
|
||||
|
||||
``{m,n}?``
|
||||
Causes the resulting RE to match from *m* to *n* repetitions of the preceding
|
||||
RE, attempting to match as *few* repetitions as possible. This is the non-
|
||||
greedy version of the previous qualifier. For example, on the 6-character
|
||||
string ``'aaaaaa'``, ``a{3,5}`` will match 5 ``'a'`` characters, while
|
||||
``a{3,5}?`` will only match 3 characters.
|
||||
RE, attempting to match as *few* repetitions as possible. This is the
|
||||
non-greedy version of the previous qualifier. For example, on the
|
||||
6-character string ``'aaaaaa'``, ``a{3,5}`` will match 5 ``'a'`` characters,
|
||||
while ``a{3,5}?`` will only match 3 characters.
|
||||
|
||||
``'\'``
|
||||
Either escapes special characters (permitting you to match characters like
|
||||
@ -519,7 +519,7 @@ form.
|
||||
If you want to locate a match anywhere in *string*, use :meth:`search` instead.
|
||||
|
||||
|
||||
.. function:: split(pattern, string[, maxsplit\ ``= 0``])
|
||||
.. function:: split(pattern, string[, maxsplit=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
|
||||
@ -673,7 +673,7 @@ attributes:
|
||||
:meth:`match` method.
|
||||
|
||||
|
||||
.. method:: RegexObject.split(string[, maxsplit\ ``= 0``])
|
||||
.. method:: RegexObject.split(string[, maxsplit=0])
|
||||
|
||||
Identical to the :func:`split` function, using the compiled pattern.
|
||||
|
||||
@ -688,12 +688,12 @@ attributes:
|
||||
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.
|
||||
|
||||
|
@ -65,8 +65,6 @@ which format specific object types.
|
||||
.. versionadded:: 2.4
|
||||
:attr:`maxset`, :attr:`maxfrozenset`, and :attr:`set`.
|
||||
|
||||
.
|
||||
|
||||
|
||||
.. attribute:: Repr.maxlong
|
||||
|
||||
|
@ -256,9 +256,9 @@ A :class:`Message` instance has the following methods:
|
||||
|
||||
:class:`Message` instances also support a limited mapping interface. In
|
||||
particular: ``m[name]`` is like ``m.getheader(name)`` but raises :exc:`KeyError`
|
||||
if there is no matching header; and ``len(m)``, ``m.get(name[, *default*])``,
|
||||
if there is no matching header; and ``len(m)``, ``m.get(name[, default])``,
|
||||
``m.has_key(name)``, ``m.keys()``, ``m.values()`` ``m.items()``, and
|
||||
``m.setdefault(name[, *default*])`` act as expected, with the one difference
|
||||
``m.setdefault(name[, default])`` act as expected, with the one difference
|
||||
that :meth:`setdefault` uses an empty string as the default value.
|
||||
:class:`Message` instances also support the mapping writable interface ``m[name]
|
||||
= value`` and ``del m[name]``. :class:`Message` objects do not support the
|
||||
|
@ -33,16 +33,16 @@ The module defines the following:
|
||||
.. function:: select(iwtd, owtd, ewtd[, timeout])
|
||||
|
||||
This is a straightforward interface to the Unix :cfunc:`select` system call.
|
||||
The first three arguments are sequences of 'waitable objects': either integers
|
||||
representing file descriptors or objects with a parameterless method named
|
||||
:meth:`fileno` returning such an integer. The three sequences of waitable
|
||||
objects are for input, output and 'exceptional conditions', respectively. Empty
|
||||
sequences are allowed, but acceptance of three empty sequences is platform-
|
||||
dependent. (It is known to work on Unix but not on Windows.) The optional
|
||||
*timeout* argument specifies a time-out as a floating point number in seconds.
|
||||
When the *timeout* argument is omitted the function blocks until at least one
|
||||
file descriptor is ready. A time-out value of zero specifies a poll and never
|
||||
blocks.
|
||||
The first three arguments are sequences of 'waitable objects': either
|
||||
integers representing file descriptors or objects with a parameterless method
|
||||
named :meth:`fileno` returning such an integer. The three sequences of
|
||||
waitable objects are for input, output and 'exceptional conditions',
|
||||
respectively. Empty sequences are allowed, but acceptance of three empty
|
||||
sequences is platform-dependent. (It is known to work on Unix but not on
|
||||
Windows.) The optional *timeout* argument specifies a time-out as a floating
|
||||
point number in seconds. When the *timeout* argument is omitted the function
|
||||
blocks until at least one file descriptor is ready. A time-out value of zero
|
||||
specifies a poll and never blocks.
|
||||
|
||||
The return value is a triple of lists of objects that are ready: subsets of the
|
||||
first three arguments. When the time-out is reached without a file descriptor
|
||||
|
@ -21,14 +21,14 @@ somewhat different interface is available in the :mod:`HTMLParser` module.
|
||||
The :class:`SGMLParser` class is instantiated without arguments. The parser is
|
||||
hardcoded to recognize the following constructs:
|
||||
|
||||
* Opening and closing tags of the form ``<tag attr="value" ...>`` and
|
||||
* Opening and closing tags of the form ``<tag attr="value" ...>`` and
|
||||
``</tag>``, respectively.
|
||||
|
||||
* Numeric character references of the form ``&#name;``.
|
||||
* Numeric character references of the form ``&#name;``.
|
||||
|
||||
* Entity references of the form ``&name;``.
|
||||
* Entity references of the form ``&name;``.
|
||||
|
||||
* SGML comments of the form ``<!--text-->``. Note that spaces, tabs, and
|
||||
* SGML comments of the form ``<!--text-->``. Note that spaces, tabs, and
|
||||
newlines are allowed between the trailing ``>`` and the immediately preceding
|
||||
``--``.
|
||||
|
||||
|
@ -15,7 +15,7 @@ This includes most class instances, recursive data types, and objects containing
|
||||
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
|
||||
|
@ -29,8 +29,8 @@ The :mod:`shlex` module defines the following functions:
|
||||
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
|
||||
(setting the :attr:`commenters` member of the :class:`shlex` instance to the
|
||||
empty string). This function operates in POSIX mode by default, but uses non-
|
||||
POSIX mode if the *posix* argument is false.
|
||||
empty string). This function operates in POSIX mode by default, but uses
|
||||
non-POSIX mode if the *posix* argument is false.
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
@ -292,7 +292,7 @@ parsing rules.
|
||||
next character that follows;
|
||||
|
||||
* Enclosing characters in quotes which are not part of :attr:`escapedquotes`
|
||||
(e.g. ``'''``) preserve the literal value of all characters within the quotes;
|
||||
(e.g. ``"'"``) preserve the literal value of all characters within the quotes;
|
||||
|
||||
* Enclosing characters in quotes which are part of :attr:`escapedquotes` (e.g.
|
||||
``'"'``) preserves the literal value of all characters within the quotes, with
|
||||
|
@ -7,9 +7,9 @@
|
||||
.. sectionauthor:: Moshe Zadka <moshez@zadka.site.co.il>
|
||||
|
||||
|
||||
The :mod:`SimpleHTTPServer` module defines a request-handler class, interface-
|
||||
compatible with :class:`BaseHTTPServer.BaseHTTPRequestHandler`, that serves
|
||||
files only from a base directory.
|
||||
The :mod:`SimpleHTTPServer` module defines a request-handler class,
|
||||
interface-compatible with :class:`BaseHTTPServer.BaseHTTPRequestHandler`, that
|
||||
serves files only from a base directory.
|
||||
|
||||
The :mod:`SimpleHTTPServer` module defines the following class:
|
||||
|
||||
|
@ -10,8 +10,8 @@
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
The :mod:`SimpleXMLRPCServer` module provides a basic server framework for XML-
|
||||
RPC servers written in Python. Servers can either be free standing, using
|
||||
The :mod:`SimpleXMLRPCServer` module provides a basic server framework for
|
||||
XML-RPC servers written in Python. Servers can either be free standing, using
|
||||
:class:`SimpleXMLRPCServer`, or embedded in a CGI environment, using
|
||||
:class:`CGIXMLRPCRequestHandler`.
|
||||
|
||||
|
@ -42,10 +42,10 @@ with ``import`` (followed by space or tab) are executed.
|
||||
triple: path; configuration; file
|
||||
|
||||
For example, suppose ``sys.prefix`` and ``sys.exec_prefix`` are set to
|
||||
:file:`/usr/local`. The Python |release| library is then installed in
|
||||
:file:`/usr/local/lib/python|version|` (where only the first three characters of
|
||||
:file:`/usr/local`. The Python X.Y library is then installed in
|
||||
:file:`/usr/local/lib/python{X.Y}` (where only the first three characters of
|
||||
``sys.version`` are used to form the installation path name). Suppose this has
|
||||
a subdirectory :file:`/usr/local/lib/python|version|/site-packages` with three
|
||||
a subdirectory :file:`/usr/local/lib/python{X.Y}/site-packages` with three
|
||||
subsubdirectories, :file:`foo`, :file:`bar` and :file:`spam`, and two path
|
||||
configuration files, :file:`foo.pth` and :file:`bar.pth`. Assume
|
||||
:file:`foo.pth` contains the following::
|
||||
|
@ -686,11 +686,11 @@ correspond to Unix system calls applicable to sockets.
|
||||
|
||||
Some notes on socket blocking and timeouts: A socket object can be in one of
|
||||
three modes: blocking, non-blocking, or timeout. Sockets are always created in
|
||||
blocking mode. In blocking mode, operations block until complete. In non-
|
||||
blocking mode, operations fail (with an error that is unfortunately system-
|
||||
dependent) if they cannot be completed immediately. In timeout mode, operations
|
||||
fail if they cannot be completed within the timeout specified for the socket.
|
||||
The :meth:`setblocking` method is simply a shorthand for certain
|
||||
blocking mode. In blocking mode, operations block until complete. In
|
||||
non-blocking mode, operations fail (with an error that is unfortunately
|
||||
system-dependent) if they cannot be completed immediately. In timeout mode,
|
||||
operations fail if they cannot be completed within the timeout specified for the
|
||||
socket. The :meth:`setblocking` method is simply a shorthand for certain
|
||||
:meth:`settimeout` calls.
|
||||
|
||||
Timeout mode internally sets the socket in non-blocking mode. The blocking and
|
||||
|
@ -13,8 +13,9 @@ protocol, which provides for continuous streams of data between the client and
|
||||
server. :class:`UDPServer` uses datagrams, which are discrete packets of
|
||||
information that may arrive out of order or be lost while in transit. The more
|
||||
infrequently used :class:`UnixStreamServer` and :class:`UnixDatagramServer`
|
||||
classes are similar, but use Unix domain sockets; they're not available on non-
|
||||
Unix platforms. For more details on network programming, consult a book such as
|
||||
classes are similar, but use Unix domain sockets; they're not available on
|
||||
non-Unix platforms. For more details on network programming, consult a book
|
||||
such as
|
||||
W. Richard Steven's UNIX Network Programming or Ralph Davis's Win32 Network
|
||||
Programming.
|
||||
|
||||
|
@ -324,9 +324,9 @@ A :class:`Connection` instance has the following attributes and methods:
|
||||
The first argument to the callback signifies what kind of operation is to be
|
||||
authorized. The second and third argument will be arguments or :const:`None`
|
||||
depending on the first argument. The 4th argument is the name of the database
|
||||
("main", "temp", etc.) if applicable. The 5th argument is the name of the inner-
|
||||
most trigger or view that is responsible for the access attempt or :const:`None`
|
||||
if this access attempt is directly from input SQL code.
|
||||
("main", "temp", etc.) if applicable. The 5th argument is the name of the
|
||||
inner-most trigger or view that is responsible for the access attempt or
|
||||
:const:`None` if this access attempt is directly from input SQL code.
|
||||
|
||||
Please consult the SQLite documentation about the possible values for the first
|
||||
argument and the meaning of the second and third argument depending on the first
|
||||
@ -344,12 +344,12 @@ A :class:`Connection` instance has the following attributes and methods:
|
||||
|
||||
.. literalinclude:: ../includes/sqlite3/row_factory.py
|
||||
|
||||
If returning a tuple doesn't suffice and you want name-based access to columns,
|
||||
you should consider setting :attr:`row_factory` to the highly-optimized
|
||||
:class:`sqlite3.Row` type. :class:`Row` provides both index-based and case-
|
||||
insensitive name-based access to columns with almost no memory overhead. It will
|
||||
probably be better than your own custom dictionary-based approach or even a
|
||||
db_row based solution.
|
||||
If returning a tuple doesn't suffice and you want name-based access to
|
||||
columns, you should consider setting :attr:`row_factory` to the
|
||||
highly-optimized :class:`sqlite3.Row` type. :class:`Row` provides both
|
||||
index-based and case-insensitive name-based access to columns with almost no
|
||||
memory overhead. It will probably be better than your own custom
|
||||
dictionary-based approach or even a db_row based solution.
|
||||
|
||||
.. % XXX what's a db_row-based solution?
|
||||
|
||||
|
@ -439,12 +439,13 @@ support:
|
||||
.. method:: container.__iter__()
|
||||
|
||||
Return an iterator object. The object is required to support the iterator
|
||||
protocol described below. If a container supports different types of iteration,
|
||||
additional methods can be provided to specifically request iterators for those
|
||||
iteration types. (An example of an object supporting multiple forms of
|
||||
iteration would be a tree structure which supports both breadth-first and depth-
|
||||
first traversal.) This method corresponds to the :attr:`tp_iter` slot of the
|
||||
type structure for Python objects in the Python/C API.
|
||||
protocol described below. If a container supports different types of
|
||||
iteration, additional methods can be provided to specifically request
|
||||
iterators for those iteration types. (An example of an object supporting
|
||||
multiple forms of iteration would be a tree structure which supports both
|
||||
breadth-first and depth-first traversal.) This method corresponds to the
|
||||
:attr:`tp_iter` slot of the type structure for Python objects in the Python/C
|
||||
API.
|
||||
|
||||
The iterator objects themselves are required to support the following two
|
||||
methods, which together form the :dfn:`iterator protocol`:
|
||||
@ -1184,9 +1185,9 @@ The conversion types are:
|
||||
Notes:
|
||||
|
||||
(1)
|
||||
The alternate form causes a leading zero (``'0'``) to be inserted between left-
|
||||
hand padding and the formatting of the number if the leading character of the
|
||||
result is not already a zero.
|
||||
The alternate form causes a leading zero (``'0'``) to be inserted between
|
||||
left-hand padding and the formatting of the number if the leading character
|
||||
of the result is not already a zero.
|
||||
|
||||
(2)
|
||||
The alternate form causes a leading ``'0x'`` or ``'0X'`` (depending on whether
|
||||
@ -1294,13 +1295,13 @@ defined on mutable sequence types (where *x* is an arbitrary object):
|
||||
| ``s.count(x)`` | return number of *i*'s for | |
|
||||
| | which ``s[i] == x`` | |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
| ``s.index(x[, *i*[, *j*]])`` | return smallest *k* such that | \(4) |
|
||||
| ``s.index(x[, i[, j]])`` | return smallest *k* such that | \(4) |
|
||||
| | ``s[k] == x`` and ``i <= k < | |
|
||||
| | j`` | |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
| ``s.insert(i, x)`` | same as ``s[i:i] = [x]`` | \(5) |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
| ``s.pop([*i*])`` | same as ``x = s[i]; del s[i]; | \(6) |
|
||||
| ``s.pop([i])`` | same as ``x = s[i]; del s[i]; | \(6) |
|
||||
| | return x`` | |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
| ``s.remove(x)`` | same as ``del s[s.index(x)]`` | \(4) |
|
||||
@ -1308,8 +1309,8 @@ defined on mutable sequence types (where *x* is an arbitrary object):
|
||||
| ``s.reverse()`` | reverses the items of *s* in | \(7) |
|
||||
| | place | |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
| ``s.sort([*cmp*[, *key*[, | sort the items of *s* in place | (7), (8), (9), (10) |
|
||||
| *reverse*]]])`` | | |
|
||||
| ``s.sort([cmp[, key[, | sort the items of *s* in place | (7), (8), (9), (10) |
|
||||
| reverse]]])`` | | |
|
||||
+------------------------------+--------------------------------+---------------------+
|
||||
|
||||
.. index::
|
||||
@ -1630,23 +1631,23 @@ mappings, *k* is a key, and *v* and *x* are arbitrary objects):
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.keys()`` | a copy of *a*'s list of keys | \(3) |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.update([*b*])`` | updates *a* with key/value | \(9) |
|
||||
| ``a.update([b])`` | updates *a* with key/value | \(9) |
|
||||
| | pairs from *b*, overwriting | |
|
||||
| | existing keys, returns ``None`` | |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.fromkeys(seq[, *value*])`` | Creates a new dictionary with | \(7) |
|
||||
| ``a.fromkeys(seq[, value])`` | Creates a new dictionary with | \(7) |
|
||||
| | keys from *seq* and values set | |
|
||||
| | to *value* | |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.values()`` | a copy of *a*'s list of values | \(3) |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.get(k[, *x*])`` | ``a[k]`` if ``k in a``, else | \(4) |
|
||||
| ``a.get(k[, x])`` | ``a[k]`` if ``k in a``, else | \(4) |
|
||||
| | *x* | |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.setdefault(k[, *x*])`` | ``a[k]`` if ``k in a``, else | \(5) |
|
||||
| ``a.setdefault(k[, x])`` | ``a[k]`` if ``k in a``, else | \(5) |
|
||||
| | *x* (also setting it) | |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.pop(k[, *x*])`` | ``a[k]`` if ``k in a``, else | \(8) |
|
||||
| ``a.pop(k[, x])`` | ``a[k]`` if ``k in a``, else | \(8) |
|
||||
| | *x* (and remove k) | |
|
||||
+--------------------------------+---------------------------------+-----------+
|
||||
| ``a.popitem()`` | remove and return an arbitrary | \(6) |
|
||||
@ -1721,13 +1722,13 @@ Notes:
|
||||
|
||||
(10)
|
||||
If a subclass of dict defines a method :meth:`__missing__`, if the key *k* is
|
||||
not present, the *a*[*k*] operation calls that method with the key *k* as
|
||||
argument. The *a*[*k*] operation then returns or raises whatever is returned or
|
||||
raised by the :func:`__missing__`\ (*k*) call if the key is not present. No
|
||||
other operations or methods invoke :meth:`__missing__`\ (). If
|
||||
:meth:`__missing__` is not defined, :exc:`KeyError` is raised.
|
||||
:meth:`__missing__` must be a method; it cannot be an instance variable. For an
|
||||
example, see :mod:`collections`.\ :class:`defaultdict`.
|
||||
not present, the ``a[k]`` operation calls that method with the key *k* as
|
||||
argument. The ``a[k]`` operation then returns or raises whatever is returned
|
||||
or raised by the ``__missing__(k)`` call if the key is not present. No other
|
||||
operations or methods invoke :meth:`__missing__`. If :meth:`__missing__` is
|
||||
not defined, :exc:`KeyError` is raised. :meth:`__missing__` must be a
|
||||
method; it cannot be an instance variable. For an example, see
|
||||
:class:`collections.defaultdict`.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
@ -1793,8 +1794,8 @@ Files have the following methods:
|
||||
|
||||
.. method:: file.flush()
|
||||
|
||||
Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`. This may be a no-
|
||||
op on some file-like objects.
|
||||
Flush the internal buffer, like ``stdio``'s :cfunc:`fflush`. This may be a
|
||||
no-op on some file-like objects.
|
||||
|
||||
|
||||
.. method:: file.fileno()
|
||||
@ -1873,11 +1874,11 @@ Files have the following methods:
|
||||
.. method:: file.readlines([sizehint])
|
||||
|
||||
Read until EOF using :meth:`readline` and return a list containing the lines
|
||||
thus read. If the optional *sizehint* argument is present, instead of reading
|
||||
up to EOF, whole lines totalling approximately *sizehint* bytes (possibly after
|
||||
rounding up to an internal buffer size) are read. Objects implementing a file-
|
||||
like interface may choose to ignore *sizehint* if it cannot be implemented, or
|
||||
cannot be implemented efficiently.
|
||||
thus read. If the optional *sizehint* argument is present, instead of
|
||||
reading up to EOF, whole lines totalling approximately *sizehint* bytes
|
||||
(possibly after rounding up to an internal buffer size) are read. Objects
|
||||
implementing a file-like interface may choose to ignore *sizehint* if it
|
||||
cannot be implemented, or cannot be implemented efficiently.
|
||||
|
||||
|
||||
.. method:: file.xreadlines()
|
||||
@ -1906,9 +1907,8 @@ Files have the following methods:
|
||||
|
||||
Note that not all file objects are seekable.
|
||||
|
||||
.. versionchanged:: Passing float values as offset has been deprecated
|
||||
|
||||
[2.6]
|
||||
.. versionchanged:: 2.6
|
||||
Passing float values as offset has been deprecated
|
||||
|
||||
|
||||
.. method:: file.tell()
|
||||
@ -1986,9 +1986,9 @@ the particular object.
|
||||
.. attribute:: file.name
|
||||
|
||||
If the file object was created using :func:`open`, the name of the file.
|
||||
Otherwise, some string that indicates the source of the file object, of the form
|
||||
``<...>``. This is a read-only attribute and may not be present on all file-
|
||||
like objects.
|
||||
Otherwise, some string that indicates the source of the file object, of the
|
||||
form ``<...>``. This is a read-only attribute and may not be present on all
|
||||
file-like objects.
|
||||
|
||||
|
||||
.. attribute:: file.newlines
|
||||
@ -2041,7 +2041,7 @@ The :dfn:`context management protocol` consists of a pair of methods that need
|
||||
to be provided for a context manager object to define a runtime context:
|
||||
|
||||
|
||||
.. method:: context manager.__enter__()
|
||||
.. method:: contextmanager.__enter__()
|
||||
|
||||
Enter the runtime context and return either this object or another object
|
||||
related to the runtime context. The value returned by this method is bound to
|
||||
@ -2060,7 +2060,7 @@ to be provided for a context manager object to define a runtime context:
|
||||
:keyword:`with` statement.
|
||||
|
||||
|
||||
.. method:: context manager.__exit__(exc_type, exc_val, exc_tb)
|
||||
.. method:: contextmanager.__exit__(exc_type, exc_val, exc_tb)
|
||||
|
||||
Exit the runtime context and return a Boolean flag indicating if any expection
|
||||
that occurred should be suppressed. If an exception occurred while executing the
|
||||
@ -2129,7 +2129,7 @@ attribute is not possible (you can write ``m.__dict__['a'] = 1``, which defines
|
||||
|
||||
Modules built into the interpreter are written like this: ``<module 'sys'
|
||||
(built-in)>``. If loaded from a file, they are written as ``<module 'os' from
|
||||
'/usr/local/lib/python|version|/os.pyc'>``.
|
||||
'/usr/local/lib/pythonX.Y/os.pyc'>``.
|
||||
|
||||
|
||||
.. _typesobjects:
|
||||
@ -2150,9 +2150,9 @@ Functions
|
||||
Function objects are created by function definitions. The only operation on a
|
||||
function object is to call it: ``func(argument-list)``.
|
||||
|
||||
There are really two flavors of function objects: built-in functions and user-
|
||||
defined functions. Both support the same operation (to call the function), but
|
||||
the implementation is different, hence the different object types.
|
||||
There are really two flavors of function objects: built-in functions and
|
||||
user-defined functions. Both support the same operation (to call the function),
|
||||
but the implementation is different, hence the different object types.
|
||||
|
||||
See :ref:`function` for more information.
|
||||
|
||||
|
@ -109,13 +109,13 @@ Instead of the normal ``%``\ -based substitutions, Templates support ``$``\
|
||||
* ``$$`` is an escape; it is replaced with a single ``$``.
|
||||
|
||||
* ``$identifier`` names a substitution placeholder matching a mapping key of
|
||||
"identifier". By default, "identifier" must spell a Python identifier. The
|
||||
first non-identifier character after the ``$`` character terminates this
|
||||
placeholder specification.
|
||||
``"identifier"``. By default, ``"identifier"`` must spell a Python
|
||||
identifier. The first non-identifier character after the ``$`` character
|
||||
terminates this placeholder specification.
|
||||
|
||||
* ``${identifier}`` is equivalent to ``$identifier``. It is required when valid
|
||||
identifier characters follow the placeholder but are not part of the
|
||||
placeholder, such as "${noun}ification".
|
||||
placeholder, such as ``"${noun}ification"``.
|
||||
|
||||
Any other appearance of ``$`` in the string will result in a :exc:`ValueError`
|
||||
being raised.
|
||||
@ -190,9 +190,10 @@ to parse template strings. To do this, you can override these class attributes:
|
||||
expression, as the implementation will call :meth:`re.escape` on this string as
|
||||
needed.
|
||||
|
||||
* *idpattern* -- This is the regular expression describing the pattern for non-
|
||||
braced placeholders (the braces will be added automatically as appropriate).
|
||||
The default value is the regular expression ``[_a-z][_a-z0-9]*``.
|
||||
* *idpattern* -- This is the regular expression describing the pattern for
|
||||
non-braced placeholders (the braces will be added automatically as
|
||||
appropriate). The default value is the regular expression
|
||||
``[_a-z][_a-z0-9]*``.
|
||||
|
||||
Alternatively, you can provide the entire regular expression pattern by
|
||||
overriding the class attribute *pattern*. If you do this, the value must be a
|
||||
|
@ -50,14 +50,14 @@ list of all functions available in the module.
|
||||
|
||||
.. function:: map_table_b2(code)
|
||||
|
||||
Return the mapped value for *code* according to tableB.2 (Mapping for case-
|
||||
folding used with NFKC).
|
||||
Return the mapped value for *code* according to tableB.2 (Mapping for
|
||||
case-folding used with NFKC).
|
||||
|
||||
|
||||
.. function:: map_table_b3(code)
|
||||
|
||||
Return the mapped value for *code* according to tableB.3 (Mapping for case-
|
||||
folding used with no normalization).
|
||||
Return the mapped value for *code* according to tableB.3 (Mapping for
|
||||
case-folding used with no normalization).
|
||||
|
||||
|
||||
.. function:: in_table_c11(code)
|
||||
|
@ -48,7 +48,7 @@ The module defines the following exception and functions:
|
||||
(``len(string)`` must equal ``calcsize(fmt)``).
|
||||
|
||||
|
||||
.. function:: unpack_from(fmt, buffer[,offset ``= 0``])
|
||||
.. function:: unpack_from(fmt, buffer[,offset=0])
|
||||
|
||||
Unpack the *buffer* according to tthe given format. The result is a tuple even
|
||||
if it contains exactly one item. The *buffer* must contain at least the amount
|
||||
@ -280,7 +280,7 @@ Compiled Struct objects support the following methods and attributes:
|
||||
(``len(string)`` must equal :attr:`self.size`).
|
||||
|
||||
|
||||
.. method:: Struct.unpack_from(buffer[,offset ``= 0``])
|
||||
.. method:: Struct.unpack_from(buffer[, offset=0])
|
||||
|
||||
Identical to the :func:`unpack_from` function, using the compiled format.
|
||||
(``len(buffer[offset:])`` must be at least :attr:`self.size`).
|
||||
|
@ -23,8 +23,8 @@ always available.
|
||||
.. data:: byteorder
|
||||
|
||||
An indicator of the native byte order. This will have the value ``'big'`` on
|
||||
big-endian (most-significant byte first) platforms, and ``'little'`` on little-
|
||||
endian (least-significant byte first) platforms.
|
||||
big-endian (most-significant byte first) platforms, and ``'little'`` on
|
||||
little-endian (least-significant byte first) platforms.
|
||||
|
||||
.. versionadded:: 2.0
|
||||
|
||||
@ -267,14 +267,14 @@ always available.
|
||||
file names, or ``None`` if the system default encoding is used. The result value
|
||||
depends on the operating system:
|
||||
|
||||
* On Windows 9x, the encoding is "mbcs".
|
||||
* On Windows 9x, the encoding is "mbcs".
|
||||
|
||||
* On Mac OS X, the encoding is "utf-8".
|
||||
* On Mac OS X, the encoding is "utf-8".
|
||||
|
||||
* On Unix, the encoding is the user's preference according to the result of
|
||||
* On Unix, the encoding is the user's preference according to the result of
|
||||
nl_langinfo(CODESET), or :const:`None` if the ``nl_langinfo(CODESET)`` failed.
|
||||
|
||||
* On Windows NT+, file names are Unicode natively, so no conversion is
|
||||
* On Windows NT+, file names are Unicode natively, so no conversion is
|
||||
performed. :func:`getfilesystemencoding` still returns ``'mbcs'``, as this is
|
||||
the encoding that applications should use when they explicitly want to convert
|
||||
Unicode strings to byte strings that are equivalent when used as file names.
|
||||
@ -369,8 +369,9 @@ always available.
|
||||
more information.)
|
||||
|
||||
The meaning of the variables is the same as that of the return values from
|
||||
:func:`exc_info` above. (Since there is only one interactive thread, thread-
|
||||
safety is not a concern for these variables, unlike for ``exc_type`` etc.)
|
||||
:func:`exc_info` above. (Since there is only one interactive thread,
|
||||
thread-safety is not a concern for these variables, unlike for ``exc_type``
|
||||
etc.)
|
||||
|
||||
|
||||
.. data:: maxint
|
||||
|
@ -32,7 +32,7 @@ use keyword arguments for clarity.
|
||||
The module defines the following user-callable functions:
|
||||
|
||||
|
||||
.. function:: TemporaryFile([mode=``'w+b'``[, bufsize=``-1``[, suffix[, prefix[, dir]]]]])
|
||||
.. function:: TemporaryFile([mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir]]]]])
|
||||
|
||||
Return a file (or file-like) object that can be used as a temporary storage
|
||||
area. The file is created using :func:`mkstemp`. It will be destroyed as soon
|
||||
@ -50,7 +50,7 @@ The module defines the following user-callable functions:
|
||||
The *dir*, *prefix* and *suffix* parameters are passed to :func:`mkstemp`.
|
||||
|
||||
|
||||
.. function:: NamedTemporaryFile([mode=``'w+b'``[, bufsize=``-1``[, suffix[, prefix[, dir[, delete]]]]]])
|
||||
.. function:: NamedTemporaryFile([mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir[, delete]]]]]])
|
||||
|
||||
This function operates exactly as :func:`TemporaryFile` does, except that the
|
||||
file is guaranteed to have a visible name in the file system (on Unix, the
|
||||
@ -66,7 +66,7 @@ The module defines the following user-callable functions:
|
||||
The *delete* parameter.
|
||||
|
||||
|
||||
.. function:: SpooledTemporaryFile([max_size=``0``, [mode=``'w+b'``[, bufsize=``-1``[, suffix[, prefix[, dir]]]]]])
|
||||
.. function:: SpooledTemporaryFile([max_size=0, [mode='w+b'[, bufsize=-1[, suffix[, prefix[, dir]]]]]])
|
||||
|
||||
This function operates exactly as :func:`TemporaryFile` does, except that data
|
||||
is spooled in memory until the file size exceeds *max_size*, or until the file's
|
||||
@ -98,13 +98,13 @@ The module defines the following user-callable functions:
|
||||
If *prefix* is specified, the file name will begin with that prefix; otherwise,
|
||||
a default prefix is used.
|
||||
|
||||
If *dir* is specified, the file will be created in that directory; otherwise, a
|
||||
default directory is used. The default directory is chosen from a platform-
|
||||
dependent list, but the user of the application can control the directory
|
||||
location by setting the *TMPDIR*, *TEMP* or *TMP* environment variables. There
|
||||
is thus no guarantee that the generated filename will have any nice properties,
|
||||
such as not requiring quoting when passed to external commands via
|
||||
``os.popen()``.
|
||||
If *dir* is specified, the file will be created in that directory; otherwise,
|
||||
a default directory is used. The default directory is chosen from a
|
||||
platform-dependent list, but the user of the application can control the
|
||||
directory location by setting the *TMPDIR*, *TEMP* or *TMP* environment
|
||||
variables. There is thus no guarantee that the generated filename will have
|
||||
any nice properties, such as not requiring quoting when passed to external
|
||||
commands via ``os.popen()``.
|
||||
|
||||
If *text* is specified, it indicates whether to open the file in binary mode
|
||||
(the default) or text mode. On some platforms, this makes no difference.
|
||||
@ -162,24 +162,24 @@ function arguments, instead.
|
||||
Python searches a standard list of directories and sets *tempdir* to the first
|
||||
one which the calling user can create files in. The list is:
|
||||
|
||||
#. The directory named by the :envvar:`TMPDIR` environment variable.
|
||||
#. The directory named by the :envvar:`TMPDIR` environment variable.
|
||||
|
||||
#. The directory named by the :envvar:`TEMP` environment variable.
|
||||
#. The directory named by the :envvar:`TEMP` environment variable.
|
||||
|
||||
#. The directory named by the :envvar:`TMP` environment variable.
|
||||
#. The directory named by the :envvar:`TMP` environment variable.
|
||||
|
||||
#. A platform-specific location:
|
||||
#. A platform-specific location:
|
||||
|
||||
* On RiscOS, the directory named by the :envvar:`Wimp$ScrapDir` environment
|
||||
* On RiscOS, the directory named by the :envvar:`Wimp$ScrapDir` environment
|
||||
variable.
|
||||
|
||||
* On Windows, the directories :file:`C:$\\TEMP`, :file:`C:$\\TMP`,
|
||||
* On Windows, the directories :file:`C:$\\TEMP`, :file:`C:$\\TMP`,
|
||||
:file:`\\TEMP`, and :file:`\\TMP`, in that order.
|
||||
|
||||
* On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and
|
||||
* On all other platforms, the directories :file:`/tmp`, :file:`/var/tmp`, and
|
||||
:file:`/usr/tmp`, in that order.
|
||||
|
||||
#. As a last resort, the current working directory.
|
||||
#. As a last resort, the current working directory.
|
||||
|
||||
|
||||
.. function:: gettempdir()
|
||||
|
@ -31,12 +31,12 @@ The module defines the following functions:
|
||||
.. function:: tcgetattr(fd)
|
||||
|
||||
Return a list containing the tty attributes for file descriptor *fd*, as
|
||||
follows: ``[``*iflag*, *oflag*, *cflag*, *lflag*, *ispeed*, *ospeed*, *cc*``]``
|
||||
where *cc* is a list of the tty special characters (each a string of length 1,
|
||||
except the items with indices :const:`VMIN` and :const:`VTIME`, which are
|
||||
integers when these fields are defined). The interpretation of the flags and
|
||||
the speeds as well as the indexing in the *cc* array must be done using the
|
||||
symbolic constants defined in the :mod:`termios` module.
|
||||
follows: ``[iflag, oflag, cflag, lflag, ispeed, ospeed, cc]`` where *cc* is a
|
||||
list of the tty special characters (each a string of length 1, except the
|
||||
items with indices :const:`VMIN` and :const:`VTIME`, which are integers when
|
||||
these fields are defined). The interpretation of the flags and the speeds as
|
||||
well as the indexing in the *cc* array must be done using the symbolic
|
||||
constants defined in the :mod:`termios` module.
|
||||
|
||||
|
||||
.. function:: tcsetattr(fd, when, attributes)
|
||||
|
@ -147,7 +147,7 @@ constructor) are as follows:
|
||||
This is generally desired for text in a monospaced font. However, the sentence
|
||||
detection algorithm is imperfect: it assumes that a sentence ending consists of
|
||||
a lowercase letter followed by one of ``'.'``, ``'!'``, or ``'?'``, possibly
|
||||
followed by one of ``'"'`` or ``'''``, followed by a space. One problem with
|
||||
followed by one of ``'"'`` or ``"'"``, followed by a space. One problem with
|
||||
this is algorithm is that it is unable to detect the difference between "Dr." in
|
||||
::
|
||||
|
||||
@ -160,9 +160,9 @@ constructor) are as follows:
|
||||
:attr:`fix_sentence_endings` is false by default.
|
||||
|
||||
Since the sentence detection algorithm relies on ``string.lowercase`` for the
|
||||
definition of "lowercase letter," and a convention of using two spaces after a
|
||||
period to separate sentences on the same line, it is specific to English-
|
||||
language texts.
|
||||
definition of "lowercase letter," and a convention of using two spaces after
|
||||
a period to separate sentences on the same line, it is specific to
|
||||
English-language texts.
|
||||
|
||||
|
||||
.. attribute:: TextWrapper.break_long_words
|
||||
@ -173,8 +173,8 @@ constructor) are as follows:
|
||||
(Long words will be put on a line by themselves, in order to minimize the amount
|
||||
by which :attr:`width` is exceeded.)
|
||||
|
||||
:class:`TextWrapper` also provides two public methods, analogous to the module-
|
||||
level convenience functions:
|
||||
:class:`TextWrapper` also provides two public methods, analogous to the
|
||||
module-level convenience functions:
|
||||
|
||||
|
||||
.. method:: TextWrapper.wrap(text)
|
||||
|
@ -197,7 +197,7 @@ and may vary across implementations.
|
||||
All methods are executed atomically.
|
||||
|
||||
|
||||
.. method:: Lock.acquire([blocking\ ``= 1``])
|
||||
.. method:: Lock.acquire([blocking=1])
|
||||
|
||||
Acquire a lock, blocking or non-blocking.
|
||||
|
||||
@ -244,7 +244,7 @@ pair) resets the lock to unlocked and allows another thread blocked in
|
||||
:meth:`acquire` to proceed.
|
||||
|
||||
|
||||
.. method:: RLock.acquire([blocking\ ``= 1``])
|
||||
.. method:: RLock.acquire([blocking=1])
|
||||
|
||||
Acquire a lock, blocking or non-blocking.
|
||||
|
||||
|
@ -20,7 +20,7 @@ for measuring execution times. See also Tim Peters' introduction to the
|
||||
The module defines the following public class:
|
||||
|
||||
|
||||
.. class:: Timer([stmt=``'pass'`` [, setup=``'pass'`` [, timer=<timer function>]]])
|
||||
.. class:: Timer([stmt='pass' [, setup='pass' [, timer=<timer function>]]])
|
||||
|
||||
Class for timing execution speed of small code snippets.
|
||||
|
||||
@ -40,7 +40,7 @@ The module defines the following public class:
|
||||
larger in this case because of the extra function calls.
|
||||
|
||||
|
||||
.. method:: Timer.print_exc([file=:const:`None`])
|
||||
.. method:: Timer.print_exc([file=None])
|
||||
|
||||
Helper to print a traceback from the timed code.
|
||||
|
||||
@ -57,7 +57,7 @@ The module defines the following public class:
|
||||
traceback is sent; it defaults to ``sys.stderr``.
|
||||
|
||||
|
||||
.. method:: Timer.repeat([repeat\ ``=3`` [, number\ ``=1000000``]])
|
||||
.. method:: Timer.repeat([repeat=3 [, number=1000000]])
|
||||
|
||||
Call :meth:`timeit` a few times.
|
||||
|
||||
@ -78,7 +78,7 @@ The module defines the following public class:
|
||||
and apply common sense rather than statistics.
|
||||
|
||||
|
||||
.. method:: Timer.timeit([number\ ``=1000000``])
|
||||
.. method:: Timer.timeit([number=1000000])
|
||||
|
||||
Time *number* executions of the main statement. This executes the setup
|
||||
statement once, and then returns the time it takes to execute the main statement
|
||||
@ -99,7 +99,7 @@ The module defines the following public class:
|
||||
Starting with version 2.6, the module also defines two convenience functions:
|
||||
|
||||
|
||||
.. function:: repeat(stmt[, setup[, timer[, repeat\ ``=3`` [, number\ ``=1000000``]]]])
|
||||
.. function:: repeat(stmt[, setup[, timer[, repeat=3 [, number=1000000]]]])
|
||||
|
||||
Create a :class:`Timer` instance with the given statement, setup code and timer
|
||||
function and run its :meth:`repeat` method with the given repeat count and
|
||||
@ -108,7 +108,7 @@ Starting with version 2.6, the module also defines two convenience functions:
|
||||
.. versionadded:: 2.6
|
||||
|
||||
|
||||
.. function:: timeit(stmt[, setup[, timer[, number\ ``=1000000``]]])
|
||||
.. function:: timeit(stmt[, setup[, timer[, number=1000000]]])
|
||||
|
||||
Create a :class:`Timer` instance with the given statement, setup code and timer
|
||||
function and run its :meth:`timeit` method with *number* executions.
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user