mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
Merged revisions 74008,74021-74022,74074-74075,74077,74148,74179,74188,74192-74194,74200,74205 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r74008 | benjamin.peterson | 2009-07-15 02:46:42 +0200 (Mi, 15 Jul 2009) | 1 line update year ........ r74021 | georg.brandl | 2009-07-16 09:33:04 +0200 (Do, 16 Jul 2009) | 1 line #6486: start with built in functions rather than "built in objects". ........ r74022 | georg.brandl | 2009-07-16 09:38:35 +0200 (Do, 16 Jul 2009) | 1 line #6481: fix typo in os.system() replacement. ........ r74074 | georg.brandl | 2009-07-18 11:03:10 +0200 (Sa, 18 Jul 2009) | 1 line #6513: fix example code: warning categories are classes, not instances. ........ r74075 | georg.brandl | 2009-07-18 11:06:31 +0200 (Sa, 18 Jul 2009) | 1 line #6505: fix typos. ........ r74077 | georg.brandl | 2009-07-18 11:43:40 +0200 (Sa, 18 Jul 2009) | 1 line #6489: fix an ambiguity in getiterator() documentation. ........ r74148 | ezio.melotti | 2009-07-21 22:18:27 +0200 (Di, 21 Jul 2009) | 1 line #6536 fixed typo ........ r74179 | ezio.melotti | 2009-07-22 23:08:49 +0200 (Mi, 22 Jul 2009) | 1 line #6423 has_key -> in ........ r74188 | benjamin.peterson | 2009-07-23 16:25:31 +0200 (Do, 23 Jul 2009) | 1 line use bools ........ r74192 | georg.brandl | 2009-07-24 18:28:38 +0200 (Fr, 24 Jul 2009) | 1 line Fix arg types of et#. ........ r74193 | georg.brandl | 2009-07-24 18:46:38 +0200 (Fr, 24 Jul 2009) | 1 line Dont put "void" in signature for nullary functions. ........ r74194 | georg.brandl | 2009-07-24 22:09:46 +0200 (Fr, 24 Jul 2009) | 1 line #6564: fix section about the two raise syntaxes. ........ r74200 | georg.brandl | 2009-07-25 15:02:15 +0200 (Sa, 25 Jul 2009) | 1 line #6571: add index entries for more operators. ........ r74205 | georg.brandl | 2009-07-26 15:36:39 +0200 (So, 26 Jul 2009) | 1 line #6576: fix cross-refs in re docs. ........
This commit is contained in:
parent
4ebc29eeca
commit
cda25a1af6
20 changed files with 99 additions and 83 deletions
|
@ -136,7 +136,7 @@ of the C variable(s) whose address should be passed.
|
||||||
In both cases, *\*buffer_length* is set to the length of the encoded data
|
In both cases, *\*buffer_length* is set to the length of the encoded data
|
||||||
without the trailing NUL byte.
|
without the trailing NUL byte.
|
||||||
|
|
||||||
``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer]
|
``et#`` (string, Unicode object or character buffer compatible object) [const char \*encoding, char \*\*buffer, int \*buffer_length]
|
||||||
Same as ``es#`` except that string objects are passed through without
|
Same as ``es#`` except that string objects are passed through without
|
||||||
recoding them. Instead, the implementation assumes that the string object
|
recoding them. Instead, the implementation assumes that the string object
|
||||||
uses the encoding passed in as parameter.
|
uses the encoding passed in as parameter.
|
||||||
|
|
|
@ -72,21 +72,21 @@ Floating Point Objects
|
||||||
.. versionadded:: 2.6
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: double PyFloat_GetMax(void)
|
.. cfunction:: double PyFloat_GetMax()
|
||||||
|
|
||||||
Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
|
Return the maximum representable finite float *DBL_MAX* as C :ctype:`double`.
|
||||||
|
|
||||||
.. versionadded:: 2.6
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: double PyFloat_GetMin(void)
|
.. cfunction:: double PyFloat_GetMin()
|
||||||
|
|
||||||
Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
|
Return the minimum normalized positive float *DBL_MIN* as C :ctype:`double`.
|
||||||
|
|
||||||
.. versionadded:: 2.6
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: int PyFloat_ClearFreeList(void)
|
.. cfunction:: int PyFloat_ClearFreeList()
|
||||||
|
|
||||||
Clear the float free list. Return the number of items that could not
|
Clear the float free list. Return the number of items that could not
|
||||||
be freed.
|
be freed.
|
||||||
|
|
|
@ -131,7 +131,7 @@ Plain Integer Objects
|
||||||
(:const:`LONG_MAX`, as defined in the system header files).
|
(:const:`LONG_MAX`, as defined in the system header files).
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: int PyInt_ClearFreeList(void)
|
.. cfunction:: int PyInt_ClearFreeList()
|
||||||
|
|
||||||
Clear the integer free list. Return the number of items that could not
|
Clear the integer free list. Return the number of items that could not
|
||||||
be freed.
|
be freed.
|
||||||
|
|
|
@ -65,7 +65,7 @@ There are some useful functions that are useful for working with method objects.
|
||||||
Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
|
Macro version of :cfunc:`PyMethod_Self` which avoids error checking.
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: int PyMethod_ClearFreeList(void)
|
.. cfunction:: int PyMethod_ClearFreeList()
|
||||||
|
|
||||||
Clear the free list. Return the total number of freed items.
|
Clear the free list. Return the total number of freed items.
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ accessible to C code. They all work with the current interpreter thread's
|
||||||
case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
|
case *name* is deleted from the sys module. Returns ``0`` on success, ``-1``
|
||||||
on error.
|
on error.
|
||||||
|
|
||||||
.. cfunction:: void PySys_ResetWarnOptions(void)
|
.. cfunction:: void PySys_ResetWarnOptions()
|
||||||
|
|
||||||
Reset :data:`sys.warnoptions` to an empty list.
|
Reset :data:`sys.warnoptions` to an empty list.
|
||||||
|
|
||||||
|
|
|
@ -157,7 +157,7 @@ Tuple Objects
|
||||||
require changes in your code for properly supporting 64-bit systems.
|
require changes in your code for properly supporting 64-bit systems.
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: int PyTuple_ClearFreeList(void)
|
.. cfunction:: int PyTuple_ClearFreeList()
|
||||||
|
|
||||||
Clear the free list. Return the total number of freed items.
|
Clear the free list. Return the total number of freed items.
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ Type Objects
|
||||||
.. versionadded:: 2.2
|
.. versionadded:: 2.2
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: unsigned int PyType_ClearCache(void)
|
.. cfunction:: unsigned int PyType_ClearCache()
|
||||||
|
|
||||||
Clear the internal lookup cache. Return the current version tag.
|
Clear the internal lookup cache. Return the current version tag.
|
||||||
|
|
||||||
|
|
|
@ -98,12 +98,13 @@ access internal read-only data of Unicode objects:
|
||||||
:ctype:`PyUnicodeObject` (not checked).
|
:ctype:`PyUnicodeObject` (not checked).
|
||||||
|
|
||||||
|
|
||||||
.. cfunction:: int PyUnicode_ClearFreeList(void)
|
.. cfunction:: int PyUnicode_ClearFreeList()
|
||||||
|
|
||||||
Clear the free list. Return the total number of freed items.
|
Clear the free list. Return the total number of freed items.
|
||||||
|
|
||||||
.. versionadded:: 2.6
|
.. versionadded:: 2.6
|
||||||
|
|
||||||
|
|
||||||
Unicode provides many different character properties. The most often needed ones
|
Unicode provides many different character properties. The most often needed ones
|
||||||
are available through these macros which are mapped to C functions depending on
|
are available through these macros which are mapped to C functions depending on
|
||||||
the Python configuration.
|
the Python configuration.
|
||||||
|
|
|
@ -4,7 +4,7 @@ Copyright
|
||||||
|
|
||||||
Python and this documentation is:
|
Python and this documentation is:
|
||||||
|
|
||||||
Copyright © 2001-2008 Python Software Foundation. All rights reserved.
|
Copyright © 2001-2009 Python Software Foundation. All rights reserved.
|
||||||
|
|
||||||
Copyright © 2000 BeOpen.com. All rights reserved.
|
Copyright © 2000 BeOpen.com. All rights reserved.
|
||||||
|
|
||||||
|
|
|
@ -488,7 +488,7 @@ than the URL you pass to .add_password() will also match. ::
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
In the above example we only supplied our ``HHTPBasicAuthHandler`` to
|
In the above example we only supplied our ``HTTPBasicAuthHandler`` to
|
||||||
``build_opener``. By default openers have the handlers for normal situations
|
``build_opener``. By default openers have the handlers for normal situations
|
||||||
-- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``,
|
-- ``ProxyHandler``, ``UnknownHandler``, ``HTTPHandler``,
|
||||||
``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
|
``HTTPDefaultErrorHandler``, ``HTTPRedirectHandler``, ``FTPHandler``,
|
||||||
|
|
|
@ -91,12 +91,13 @@ form contents from standard input or the environment (depending on the value of
|
||||||
various environment variables set according to the CGI standard). Since it may
|
various environment variables set according to the CGI standard). Since it may
|
||||||
consume standard input, it should be instantiated only once.
|
consume standard input, it should be instantiated only once.
|
||||||
|
|
||||||
The :class:`FieldStorage` instance can be indexed like a Python dictionary, and
|
The :class:`FieldStorage` instance can be indexed like a Python dictionary.
|
||||||
also supports the standard dictionary methods :meth:`has_key` and :meth:`keys`.
|
It allows membership testing with the :keyword:`in` operator, and also supports
|
||||||
The built-in :func:`len` is also supported. Form fields containing empty
|
the standard dictionary method :meth:`keys` and the built-in function
|
||||||
strings are ignored and do not appear in the dictionary; to keep such values,
|
:func:`len`. Form fields containing empty strings are ignored and do not appear
|
||||||
provide a true value for the optional *keep_blank_values* keyword parameter when
|
in the dictionary; to keep such values, provide a true value for the optional
|
||||||
creating the :class:`FieldStorage` instance.
|
*keep_blank_values* keyword parameter when creating the :class:`FieldStorage`
|
||||||
|
instance.
|
||||||
|
|
||||||
For instance, the following code (which assumes that the
|
For instance, the following code (which assumes that the
|
||||||
:mailheader:`Content-Type` header and blank line have already been printed)
|
:mailheader:`Content-Type` header and blank line have already been printed)
|
||||||
|
@ -104,7 +105,7 @@ checks that the fields ``name`` and ``addr`` are both set to a non-empty
|
||||||
string::
|
string::
|
||||||
|
|
||||||
form = cgi.FieldStorage()
|
form = cgi.FieldStorage()
|
||||||
if not (form.has_key("name") and form.has_key("addr")):
|
if "name" not in form or "addr" not in form:
|
||||||
print "<H1>Error</H1>"
|
print "<H1>Error</H1>"
|
||||||
print "Please fill in the name and addr fields."
|
print "Please fill in the name and addr fields."
|
||||||
return
|
return
|
||||||
|
|
|
@ -44,8 +44,9 @@ browse the table of contents (in front of the manual), or look for a specific
|
||||||
function, module or term in the index (in the back). And finally, if you enjoy
|
function, module or term in the index (in the back). And finally, if you enjoy
|
||||||
learning about random subjects, you choose a random page number (see module
|
learning about random subjects, you choose a random page number (see module
|
||||||
:mod:`random`) and read a section or two. Regardless of the order in which you
|
:mod:`random`) and read a section or two. Regardless of the order in which you
|
||||||
read the sections of this manual, it helps to start with chapter :ref:`builtin`,
|
read the sections of this manual, it helps to start with chapter
|
||||||
as the remainder of the manual assumes familiarity with this material.
|
:ref:`built-in-funcs`, as the remainder of the manual assumes familiarity with
|
||||||
|
this material.
|
||||||
|
|
||||||
Let the show begin!
|
Let the show begin!
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ The special characters are:
|
||||||
flags are described in :ref:`contents-of-module-re`.) This
|
flags are described in :ref:`contents-of-module-re`.) This
|
||||||
is useful if you wish to include the flags as part of the regular
|
is useful if you wish to include the flags as part of the regular
|
||||||
expression, instead of passing a *flag* argument to the
|
expression, instead of passing a *flag* argument to the
|
||||||
:func:`compile` function.
|
:func:`re.compile` function.
|
||||||
|
|
||||||
Note that the ``(?x)`` flag changes how the expression is parsed. It should be
|
Note that the ``(?x)`` flag changes how the expression is parsed. It should be
|
||||||
used first in the expression string, or after one or more whitespace characters.
|
used first in the expression string, or after one or more whitespace characters.
|
||||||
|
@ -443,9 +443,9 @@ form.
|
||||||
|
|
||||||
result = re.match(pattern, string)
|
result = re.match(pattern, string)
|
||||||
|
|
||||||
but using :func:`compile` and saving the resulting regular expression object
|
but using :func:`re.compile` and saving the resulting regular expression
|
||||||
for reuse is more efficient when the expression will be used several times
|
object for reuse is more efficient when the expression will be used several
|
||||||
in a single program.
|
times in a single program.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
@ -532,7 +532,7 @@ form.
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If you want to locate a match anywhere in *string*, use :meth:`search`
|
If you want to locate a match anywhere in *string*, use :func:`search`
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
|
||||||
|
@ -686,8 +686,8 @@ attributes:
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
If you want to locate a match anywhere in *string*, use :meth:`search`
|
If you want to locate a match anywhere in *string*, use
|
||||||
instead.
|
:meth:`~RegexObject.search` instead.
|
||||||
|
|
||||||
The optional second parameter *pos* gives an index in the string where the
|
The optional second parameter *pos* gives an index in the string where the
|
||||||
search is to start; it defaults to ``0``. This is not completely equivalent to
|
search is to start; it defaults to ``0``. This is not completely equivalent to
|
||||||
|
@ -716,7 +716,7 @@ attributes:
|
||||||
is different from finding a zero-length match at some point in the string.
|
is different from finding a zero-length match at some point in the string.
|
||||||
|
|
||||||
The optional *pos* and *endpos* parameters have the same meaning as for the
|
The optional *pos* and *endpos* parameters have the same meaning as for the
|
||||||
:meth:`match` method.
|
:meth:`~RegexObject.match` method.
|
||||||
|
|
||||||
|
|
||||||
.. method:: RegexObject.split(string[, maxsplit=0])
|
.. method:: RegexObject.split(string[, maxsplit=0])
|
||||||
|
@ -780,10 +780,10 @@ support the following methods and attributes:
|
||||||
.. method:: MatchObject.expand(template)
|
.. method:: MatchObject.expand(template)
|
||||||
|
|
||||||
Return the string obtained by doing backslash substitution on the template
|
Return the string obtained by doing backslash substitution on the template
|
||||||
string *template*, as done by the :meth:`sub` method. Escapes such as ``\n`` are
|
string *template*, as done by the :meth:`~RegexObject.sub` method. Escapes
|
||||||
converted to the appropriate characters, and numeric backreferences (``\1``,
|
such as ``\n`` are converted to the appropriate characters, and numeric
|
||||||
``\2``) and named backreferences (``\g<1>``, ``\g<name>``) are replaced by the
|
backreferences (``\1``, ``\2``) and named backreferences (``\g<1>``,
|
||||||
contents of the corresponding group.
|
``\g<name>``) are replaced by the contents of the corresponding group.
|
||||||
|
|
||||||
|
|
||||||
.. method:: MatchObject.group([group1, ...])
|
.. method:: MatchObject.group([group1, ...])
|
||||||
|
@ -907,16 +907,16 @@ support the following methods and attributes:
|
||||||
|
|
||||||
.. attribute:: MatchObject.pos
|
.. attribute:: MatchObject.pos
|
||||||
|
|
||||||
The value of *pos* which was passed to the :func:`search` or :func:`match`
|
The value of *pos* which was passed to the :meth:`~RegexObject.search` or
|
||||||
method of the :class:`RegexObject`. This is the index into the string at which
|
:meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
|
||||||
the RE engine started looking for a match.
|
index into the string at which the RE engine started looking for a match.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.endpos
|
.. attribute:: MatchObject.endpos
|
||||||
|
|
||||||
The value of *endpos* which was passed to the :func:`search` or :func:`match`
|
The value of *endpos* which was passed to the :meth:`~RegexObject.search` or
|
||||||
method of the :class:`RegexObject`. This is the index into the string beyond
|
:meth:`~RegexObject.match` method of the :class:`RegexObject`. This is the
|
||||||
which the RE engine will not go.
|
index into the string beyond which the RE engine will not go.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.lastindex
|
.. attribute:: MatchObject.lastindex
|
||||||
|
@ -936,13 +936,15 @@ support the following methods and attributes:
|
||||||
|
|
||||||
.. attribute:: MatchObject.re
|
.. attribute:: MatchObject.re
|
||||||
|
|
||||||
The regular expression object whose :meth:`match` or :meth:`search` method
|
The regular expression object whose :meth:`~RegexObject.match` or
|
||||||
produced this :class:`MatchObject` instance.
|
:meth:`~RegexObject.search` method produced this :class:`MatchObject`
|
||||||
|
instance.
|
||||||
|
|
||||||
|
|
||||||
.. attribute:: MatchObject.string
|
.. attribute:: MatchObject.string
|
||||||
|
|
||||||
The string passed to :func:`match` or :func:`search`.
|
The string passed to :meth:`~RegexObject.match` or
|
||||||
|
:meth:`~RegexObject.search`.
|
||||||
|
|
||||||
|
|
||||||
Examples
|
Examples
|
||||||
|
@ -987,8 +989,9 @@ To match this with a regular expression, one could use backreferences as such:
|
||||||
>>> displaymatch(pair.match("354aa")) # Pair of aces.
|
>>> displaymatch(pair.match("354aa")) # Pair of aces.
|
||||||
"<Match: '354aa', groups=('a',)>"
|
"<Match: '354aa', groups=('a',)>"
|
||||||
|
|
||||||
To find out what card the pair consists of, one could use the :func:`group`
|
To find out what card the pair consists of, one could use the
|
||||||
method of :class:`MatchObject` in the following manner:
|
:meth:`~MatchObject.group` method of :class:`MatchObject` in the following
|
||||||
|
manner:
|
||||||
|
|
||||||
.. doctest::
|
.. doctest::
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,17 @@ Notes:
|
||||||
Comparisons
|
Comparisons
|
||||||
===========
|
===========
|
||||||
|
|
||||||
.. index:: pair: chaining; comparisons
|
.. index::
|
||||||
|
pair: chaining; comparisons
|
||||||
|
pair: operator; comparison
|
||||||
|
operator: ==
|
||||||
|
operator: <
|
||||||
|
operator: <=
|
||||||
|
operator: >
|
||||||
|
operator: >=
|
||||||
|
operator: !=
|
||||||
|
operator: is
|
||||||
|
operator: is not
|
||||||
|
|
||||||
Comparison operations are supported by all objects. They all have the same
|
Comparison operations are supported by all objects. They all have the same
|
||||||
priority (which is higher than that of the Boolean operations). Comparisons can
|
priority (which is higher than that of the Boolean operations). Comparisons can
|
||||||
|
@ -159,17 +169,6 @@ This table summarizes the comparison operations:
|
||||||
| ``is not`` | negated object identity | |
|
| ``is not`` | negated object identity | |
|
||||||
+------------+-------------------------+-------+
|
+------------+-------------------------+-------+
|
||||||
|
|
||||||
.. index::
|
|
||||||
pair: operator; comparison
|
|
||||||
operator: ==
|
|
||||||
operator: <
|
|
||||||
operator: <=
|
|
||||||
operator: >
|
|
||||||
operator: >=
|
|
||||||
operator: !=
|
|
||||||
operator: is
|
|
||||||
operator: is not
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
(1)
|
(1)
|
||||||
|
@ -262,6 +261,13 @@ part.
|
||||||
builtin: long
|
builtin: long
|
||||||
builtin: float
|
builtin: float
|
||||||
builtin: complex
|
builtin: complex
|
||||||
|
operator: +
|
||||||
|
operator: -
|
||||||
|
operator: *
|
||||||
|
operator: /
|
||||||
|
operator: //
|
||||||
|
operator: %
|
||||||
|
operator: **
|
||||||
|
|
||||||
Python fully supports mixed arithmetic: when a binary arithmetic operator has
|
Python fully supports mixed arithmetic: when a binary arithmetic operator has
|
||||||
operands of different numeric types, the operand with the "narrower" type is
|
operands of different numeric types, the operand with the "narrower" type is
|
||||||
|
@ -394,7 +400,15 @@ All :class:`numbers.Real` types (:class:`int`, :class:`long`, and
|
||||||
Bit-string Operations on Integer Types
|
Bit-string Operations on Integer Types
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
.. _bit-string-operations:
|
.. index::
|
||||||
|
triple: operations on; integer; types
|
||||||
|
pair: bit-string; operations
|
||||||
|
pair: shifting; operations
|
||||||
|
pair: masking; operations
|
||||||
|
operator: ^
|
||||||
|
operator: &
|
||||||
|
operator: <<
|
||||||
|
operator: >>
|
||||||
|
|
||||||
Plain and long integer types support additional operations that make sense only
|
Plain and long integer types support additional operations that make sense only
|
||||||
for bit-strings. Negative numbers are treated as their 2's complement value
|
for bit-strings. Negative numbers are treated as their 2's complement value
|
||||||
|
@ -426,12 +440,6 @@ This table lists the bit-string operations sorted in ascending priority:
|
||||||
| ``~x`` | the bits of *x* inverted | |
|
| ``~x`` | the bits of *x* inverted | |
|
||||||
+------------+--------------------------------+----------+
|
+------------+--------------------------------+----------+
|
||||||
|
|
||||||
.. index::
|
|
||||||
triple: operations on; integer; types
|
|
||||||
pair: bit-string; operations
|
|
||||||
pair: shifting; operations
|
|
||||||
pair: masking; operations
|
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
(1)
|
(1)
|
||||||
|
|
|
@ -369,7 +369,7 @@ Replacing :func:`os.system`
|
||||||
sts = os.system("mycmd" + " myarg")
|
sts = os.system("mycmd" + " myarg")
|
||||||
==>
|
==>
|
||||||
p = Popen("mycmd" + " myarg", shell=True)
|
p = Popen("mycmd" + " myarg", shell=True)
|
||||||
sts = os.waitpid(p.pid, 0)
|
sts = os.waitpid(p.pid, 0)[1]
|
||||||
|
|
||||||
Notes:
|
Notes:
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ check::
|
||||||
fxn()
|
fxn()
|
||||||
# Verify some things
|
# Verify some things
|
||||||
assert len(w) == 1
|
assert len(w) == 1
|
||||||
assert isinstance(w[-1].category, DeprecationWarning)
|
assert issubclass(w[-1].category, DeprecationWarning)
|
||||||
assert "deprecated" in str(w[-1].message)
|
assert "deprecated" in str(w[-1].message)
|
||||||
|
|
||||||
One can also cause all warnings to be exceptions by using ``error`` instead of
|
One can also cause all warnings to be exceptions by using ``error`` instead of
|
||||||
|
|
|
@ -46,14 +46,14 @@ The following exception is defined:
|
||||||
The following functions are defined:
|
The following functions are defined:
|
||||||
|
|
||||||
|
|
||||||
.. function:: open(url[, new=0[, autoraise=1]])
|
.. function:: open(url[, new=0[, autoraise=True]])
|
||||||
|
|
||||||
Display *url* using the default browser. If *new* is 0, the *url* is opened in
|
Display *url* using the default browser. If *new* is 0, the *url* is opened
|
||||||
the same browser window if possible. If *new* is 1, a new browser window is
|
in the same browser window if possible. If *new* is 1, a new browser window
|
||||||
opened if possible. If *new* is 2, a new browser page ("tab") is opened if
|
is opened if possible. If *new* is 2, a new browser page ("tab") is opened
|
||||||
possible. If *autoraise* is true, the window is raised if possible (note that
|
if possible. If *autoraise* is ``True``, the window is raised if possible
|
||||||
under many window managers this will occur regardless of the setting of this
|
(note that under many window managers this will occur regardless of the
|
||||||
variable).
|
setting of this variable).
|
||||||
|
|
||||||
Note that on some platforms, trying to open a filename using this function,
|
Note that on some platforms, trying to open a filename using this function,
|
||||||
may work and start the operating system's associated program. However, this
|
may work and start the operating system's associated program. However, this
|
||||||
|
@ -180,7 +180,7 @@ Browser controllers provide these methods which parallel three of the
|
||||||
module-level convenience functions:
|
module-level convenience functions:
|
||||||
|
|
||||||
|
|
||||||
.. method:: controller.open(url[, new[, autoraise=1]])
|
.. method:: controller.open(url[, new[, autoraise=True]])
|
||||||
|
|
||||||
Display *url* using the browser handled by this controller. If *new* is 1, a new
|
Display *url* using the browser handled by this controller. If *new* is 1, a new
|
||||||
browser window is opened if possible. If *new* is 2, a new browser page ("tab")
|
browser window is opened if possible. If *new* is 2, a new browser page ("tab")
|
||||||
|
|
|
@ -262,9 +262,9 @@ The following methods work on the element's children (subelements).
|
||||||
.. method:: Element.getiterator([tag=None])
|
.. method:: Element.getiterator([tag=None])
|
||||||
|
|
||||||
Creates a tree iterator with the current element as the root. The iterator
|
Creates a tree iterator with the current element as the root. The iterator
|
||||||
iterates over this element and all elements below it that match the given tag.
|
iterates over this element and all elements below it, in document (depth first)
|
||||||
If tag is ``None`` or ``'*'`` then all elements are iterated over. Returns an
|
order. If *tag* is not ``None`` or ``'*'``, only elements whose tag equals
|
||||||
iterable that provides element objects in document (depth first) order.
|
*tag* are returned from the iterator.
|
||||||
|
|
||||||
|
|
||||||
.. method:: Element.insert(index, element)
|
.. method:: Element.insert(index, element)
|
||||||
|
|
|
@ -221,9 +221,11 @@ exception to occur. For example::
|
||||||
File "<stdin>", line 1, in ?
|
File "<stdin>", line 1, in ?
|
||||||
NameError: HiThere
|
NameError: HiThere
|
||||||
|
|
||||||
The sole argument to :keyword:`raise` indicates the exception to be raised.
|
The argument to :keyword:`raise` is an exception class or instance to be
|
||||||
This must be either an exception instance or an exception class (a class that
|
raised. There is a deprecated alternate syntax that separates class and
|
||||||
derives from :class:`Exception`).
|
constructor arguments; the above could be written as ``raise NameError,
|
||||||
|
'HiThere'``. Since it once was the only one available, the latter form is
|
||||||
|
prevalent in older code.
|
||||||
|
|
||||||
If you need to determine whether an exception was raised but don't intend to
|
If you need to determine whether an exception was raised but don't intend to
|
||||||
handle it, a simpler form of the :keyword:`raise` statement allows you to
|
handle it, a simpler form of the :keyword:`raise` statement allows you to
|
||||||
|
|
|
@ -148,9 +148,9 @@ Positional and keyword arguments can be arbitrarily combined::
|
||||||
... other='Georg')
|
... other='Georg')
|
||||||
The story of Bill, Manfred, and Georg.
|
The story of Bill, Manfred, and Georg.
|
||||||
|
|
||||||
An optional ``':'`` and format specifier can follow the field name. This also
|
An optional ``':'`` and format specifier can follow the field name. This allows
|
||||||
greater control over how the value is formatted. The following example
|
greater control over how the value is formatted. The following example
|
||||||
truncates the Pi to three places after the decimal.
|
truncates Pi to three places after the decimal.
|
||||||
|
|
||||||
>>> import math
|
>>> import math
|
||||||
>>> print 'The value of PI is approximately {0:.3f}.'.format(math.pi)
|
>>> print 'The value of PI is approximately {0:.3f}.'.format(math.pi)
|
||||||
|
@ -204,8 +204,8 @@ operation. For example::
|
||||||
The value of PI is approximately 3.142.
|
The value of PI is approximately 3.142.
|
||||||
|
|
||||||
Since :meth:`str.format` is quite new, a lot of Python code still uses the ``%``
|
Since :meth:`str.format` is quite new, a lot of Python code still uses the ``%``
|
||||||
operator. However, because this old style of formatting will eventually removed
|
operator. However, because this old style of formatting will eventually be
|
||||||
from the language :meth:`str.format` should generally be used.
|
removed from the language, :meth:`str.format` should generally be used.
|
||||||
|
|
||||||
More information can be found in the :ref:`string-formatting` section.
|
More information can be found in the :ref:`string-formatting` section.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue