diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-03-21 17:31:58 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-03-21 17:31:58 (GMT) |
commit | f07d0026da4330724ae2f17fb453db3d7f539e56 (patch) | |
tree | c5e5b64602dc0ed367980f0630289a003953c4ce /Doc | |
parent | 839d6cac82fce91cb655ff65aeecc07554e1e81b (diff) | |
download | cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.zip cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.tar.gz cpython-f07d0026da4330724ae2f17fb453db3d7f539e56.tar.bz2 |
Merged revisions 70342,70385-70387,70389-70390,70392-70393,70395,70400,70405-70406,70418,70438,70464,70468 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r70342 | georg.brandl | 2009-03-13 14:03:58 -0500 (Fri, 13 Mar 2009) | 1 line
#5486: typos.
........
r70385 | benjamin.peterson | 2009-03-15 09:38:55 -0500 (Sun, 15 Mar 2009) | 1 line
fix tuple.index() error message #5495
........
r70386 | georg.brandl | 2009-03-15 16:32:06 -0500 (Sun, 15 Mar 2009) | 1 line
#5496: fix docstring of lookup().
........
r70387 | georg.brandl | 2009-03-15 16:37:16 -0500 (Sun, 15 Mar 2009) | 1 line
#5493: clarify __nonzero__ docs.
........
r70389 | georg.brandl | 2009-03-15 16:43:38 -0500 (Sun, 15 Mar 2009) | 1 line
Fix a small nit in the error message if bool() falls back on __len__ and it returns the wrong type: it would tell the user that __nonzero__ should return bool or int.
........
r70390 | georg.brandl | 2009-03-15 16:44:43 -0500 (Sun, 15 Mar 2009) | 1 line
#5491: clarify nested() semantics.
........
r70392 | georg.brandl | 2009-03-15 16:46:00 -0500 (Sun, 15 Mar 2009) | 1 line
#5488: add missing struct member.
........
r70393 | georg.brandl | 2009-03-15 16:47:42 -0500 (Sun, 15 Mar 2009) | 1 line
#5478: fix copy-paste oversight in function signature.
........
r70395 | georg.brandl | 2009-03-15 16:51:48 -0500 (Sun, 15 Mar 2009) | 1 line
#5276: document IDLESTARTUP and .Idle.py.
........
r70400 | georg.brandl | 2009-03-15 16:59:37 -0500 (Sun, 15 Mar 2009) | 3 lines
Fix markup in re docs and give a mail address in regex howto, so that
the recommendation to send suggestions to the author can be followed.
........
r70405 | georg.brandl | 2009-03-15 17:11:07 -0500 (Sun, 15 Mar 2009) | 7 lines
Move the previously local import of threading to module level.
This is cleaner and avoids lockups in obscure cases where a Queue
is instantiated while the import lock is already held by another thread.
OKed by Tim Peters.
........
r70406 | hirokazu.yamamoto | 2009-03-15 17:43:14 -0500 (Sun, 15 Mar 2009) | 1 line
Added skip for old MSVC.
........
r70418 | georg.brandl | 2009-03-16 14:42:03 -0500 (Mon, 16 Mar 2009) | 1 line
Add token markup.
........
r70438 | benjamin.peterson | 2009-03-17 15:29:51 -0500 (Tue, 17 Mar 2009) | 1 line
I thought this was begging for an example
........
r70464 | benjamin.peterson | 2009-03-18 15:58:09 -0500 (Wed, 18 Mar 2009) | 1 line
a much better example
........
r70468 | benjamin.peterson | 2009-03-18 22:04:31 -0500 (Wed, 18 Mar 2009) | 1 line
close files after comparing them
........
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/c-api/typeobj.rst | 1 | ||||
-rw-r--r-- | Doc/howto/regex.rst | 2 | ||||
-rw-r--r-- | Doc/library/contextlib.rst | 9 | ||||
-rw-r--r-- | Doc/library/functions.rst | 8 | ||||
-rw-r--r-- | Doc/library/idle.rst | 18 | ||||
-rw-r--r-- | Doc/library/re.rst | 2 | ||||
-rw-r--r-- | Doc/library/string.rst | 2 | ||||
-rw-r--r-- | Doc/library/xml.dom.rst | 2 | ||||
-rw-r--r-- | Doc/reference/datamodel.rst | 11 |
9 files changed, 42 insertions, 13 deletions
diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 2e2f9c4..eba8d69 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -1052,6 +1052,7 @@ Number Object Structures binaryfunc nb_inplace_add; binaryfunc nb_inplace_subtract; binaryfunc nb_inplace_multiply; + binaryfunc nb_inplace_divide; binaryfunc nb_inplace_remainder; ternaryfunc nb_inplace_power; binaryfunc nb_inplace_lshift; diff --git a/Doc/howto/regex.rst b/Doc/howto/regex.rst index c74fd39..3ed5368 100644 --- a/Doc/howto/regex.rst +++ b/Doc/howto/regex.rst @@ -4,7 +4,7 @@ Regular Expression HOWTO **************************** -:Author: A.M. Kuchling +:Author: A.M. Kuchling <amk@amk.ca> :Release: 0.05 .. TODO: diff --git a/Doc/library/contextlib.rst b/Doc/library/contextlib.rst index 74a68cf..e2ca6a1 100644 --- a/Doc/library/contextlib.rst +++ b/Doc/library/contextlib.rst @@ -61,14 +61,15 @@ Functions provided: from contextlib import nested - with nested(A, B, C) as (X, Y, Z): + with nested(A(), B(), C()) as (X, Y, Z): do_something() is equivalent to this:: - with A as X: - with B as Y: - with C as Z: + m1, m2, m3 = A(), B(), C() + with m1 as X: + with m2 as Y: + with m3 as Z: do_something() Note that if the :meth:`__exit__` method of one of the nested context managers diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index e807e79..4d8a845 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -561,6 +561,14 @@ are always available. They are listed here in alphabetical order. its :meth:`__next__` method; if the value returned is equal to *sentinel*, :exc:`StopIteration` will be raised, otherwise the value will be returned. + One useful application of the second form of :func:`iter` is to read lines of + a file until a certain line is reached. The following example reads a file + until ``"STOP"`` is reached: :: + + with open("mydata.txt") as fp: + for line in iter(fp.readline, "STOP"): + process_line(line) + .. function:: len(s) diff --git a/Doc/library/idle.rst b/Doc/library/idle.rst index 413750f..1b78fb9 100644 --- a/Doc/library/idle.rst +++ b/Doc/library/idle.rst @@ -253,6 +253,24 @@ Shell colors: black +Startup +------- + +Upon startup with the ``-s`` option, IDLE will execute the file referenced by +the environment variables :envvar:`IDLESTARTUP` or :envvar:`PYTHONSTARTUP`. +Idle first checks for ``IDLESTARTUP``; if ``IDLESTARTUP`` is present the file +referenced is run. If ``IDLESTARTUP`` is not present, Idle checks for +``PYTHONSTARTUP``. Files referenced by these environment variables are +convenient places to store functions that are used frequently from the Idle +shell, or for executing import statements to import common modules. + +In addition, ``Tk`` also loads a startup file if it is present. Note that the +Tk file is loaded unconditionally. This additional file is ``.Idle.py`` and is +looked for in the user's home directory. Statements in this file will be +executed in the Tk namespace, so this file is not useful for importing functions +to be used from Idle's Python shell. + + Command line usage ^^^^^^^^^^^^^^^^^^ diff --git a/Doc/library/re.rst b/Doc/library/re.rst index 6e499a0..0dbd0e2 100644 --- a/Doc/library/re.rst +++ b/Doc/library/re.rst @@ -1127,7 +1127,7 @@ For example: string)`` or ``re.search(pattern, string)``. :func:`match` has an optional second parameter that gives an index in the string -where the search is to start: +where the search is to start:: >>> pattern = re.compile("o") >>> pattern.match("dog") # No match as "o" is not at the start of "dog." diff --git a/Doc/library/string.rst b/Doc/library/string.rst index 98c7051..2e444ad 100644 --- a/Doc/library/string.rst +++ b/Doc/library/string.rst @@ -196,7 +196,7 @@ The grammar for a replacement field is as follows: .. productionlist:: sf replacement_field: "{" `field_name` ["!" `conversion`] [":" `format_spec`] "}" - field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" element_index "]")* + field_name: (`identifier` | `integer`) ("." `attribute_name` | "[" `element_index` "]")* attribute_name: `identifier` element_index: `integer` conversion: "r" | "s" | "a" diff --git a/Doc/library/xml.dom.rst b/Doc/library/xml.dom.rst index 2a0c788..bf1b151 100644 --- a/Doc/library/xml.dom.rst +++ b/Doc/library/xml.dom.rst @@ -600,7 +600,7 @@ of that class. Same as equivalent method in the :class:`Document` class. -.. method:: Element.getElementsByTagNameNS(tagName) +.. method:: Element.getElementsByTagNameNS(namespaceURI, localName) Same as equivalent method in the :class:`Document` class. diff --git a/Doc/reference/datamodel.rst b/Doc/reference/datamodel.rst index 2e4a776..49f2be6 100644 --- a/Doc/reference/datamodel.rst +++ b/Doc/reference/datamodel.rst @@ -1251,11 +1251,12 @@ Basic customization .. index:: single: __len__() (mapping object method) - Called to implement truth value testing, and the built-in operation ``bool()``; - should return ``False`` or ``True``. When this method is not defined, - :meth:`__len__` is called, if it is defined (see below) and ``True`` is returned - when the length is not zero. If a class defines neither :meth:`__len__` nor - :meth:`__bool__`, all its instances are considered true. + Called to implement truth value testing and the built-in operation + ``bool()``; should return ``False`` or ``True``, or their integer equivalents + ``0`` or ``1``. When this method is not defined, :meth:`__len__` is called, + if it is defined, and the object is considered true if its result is nonzero. + If a class defines neither :meth:`__len__` nor :meth:`__bool__`, all its + instances are considered true. .. _attribute-access: |