summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2008-01-14 18:49:24 (GMT)
committerChristian Heimes <christian@cheimes.de>2008-01-14 18:49:24 (GMT)
commitd32ed6f5117a68037e9cb7bcfd8d0f8d1611f442 (patch)
tree9e2893323fe2a217827f43ee53e92f8de9b1cf99 /Doc
parent1acde190b2676ecfa45d754667df36d6b9c9cc7e (diff)
downloadcpython-d32ed6f5117a68037e9cb7bcfd8d0f8d1611f442.zip
cpython-d32ed6f5117a68037e9cb7bcfd8d0f8d1611f442.tar.gz
cpython-d32ed6f5117a68037e9cb7bcfd8d0f8d1611f442.tar.bz2
Merged revisions 59933-59951 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59935 | raymond.hettinger | 2008-01-13 07:15:15 +0100 (Sun, 13 Jan 2008) | 1 line Named tuple is a concept, not a specific type. ........ r59936 | raymond.hettinger | 2008-01-13 07:18:07 +0100 (Sun, 13 Jan 2008) | 1 line Fix spelling. ........ r59937 | georg.brandl | 2008-01-13 10:36:18 +0100 (Sun, 13 Jan 2008) | 2 lines Clarify the effect of text mode. ........ r59938 | thomas.heller | 2008-01-13 12:19:43 +0100 (Sun, 13 Jan 2008) | 1 line Make Modules/socketobject.c compile for Windows again. ........ r59939 | ka-ping.yee | 2008-01-13 12:25:13 +0100 (Sun, 13 Jan 2008) | 9 lines Check in the patch proposed by Ben Hayden (benjhayden) for issue #1550: help('modules') broken by several 3rd party libraries. Tested with Python build: trunk:54235:59936M -- the reported error occurs with Django installed (or with any __init__.py present on the path that raises an exception), and such errors indeed go away when this change is applied. ........ r59940 | georg.brandl | 2008-01-13 16:04:05 +0100 (Sun, 13 Jan 2008) | 2 lines Back out r59931 - test_ctypes fails with it. ........ r59943 | amaury.forgeotdarc | 2008-01-14 01:22:44 +0100 (Mon, 14 Jan 2008) | 6 lines As discussed in issue 1700288: ctypes takes some liberties when creating python types: it modifies the types' __dict__ directly, bypassing all the machinery of type objects which deal with special methods. And this broke recent optimisations of method lookup. Now we try to modify the type with more "official" functions. ........ r59944 | amaury.forgeotdarc | 2008-01-14 01:29:41 +0100 (Mon, 14 Jan 2008) | 5 lines Re-apply patch #1700288 (first applied in r59931, rolled back in r59940) now that ctypes uses a more supported method to create types: Method cache optimization, by Armin Rigo, ported to 2.6 by Kevin Jacobs. ........ r59946 | amaury.forgeotdarc | 2008-01-14 02:07:27 +0100 (Mon, 14 Jan 2008) | 4 lines ?Why did my tests not notice this before? Slots inheritance is very different from OO inheritance. This code lead to infinite recursion on classes derived from StructType. ........ r59947 | christian.heimes | 2008-01-14 04:33:52 +0100 (Mon, 14 Jan 2008) | 1 line Added new an better structseq representation. E.g. repr(time.gmtime(0)) now returns 'time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)' instead of '(1970, 1, 1, 0, 0, 0, 3, 1, 0)'. The feature is part of #1816: sys.flags ........ r59948 | christian.heimes | 2008-01-14 04:35:38 +0100 (Mon, 14 Jan 2008) | 1 line I missed the most important file ........ r59949 | christian.heimes | 2008-01-14 04:42:48 +0100 (Mon, 14 Jan 2008) | 1 line Applied patch #1816: sys.flags patch ........ r59950 | christian.heimes | 2008-01-14 05:13:37 +0100 (Mon, 14 Jan 2008) | 2 lines Now that I've learnt about structseq objects I felt like converting sys.float_info to a structseq. It's readonly and help(sys.float_info) explains the attributes nicely. ........ r59951 | christian.heimes | 2008-01-14 07:06:19 +0100 (Mon, 14 Jan 2008) | 1 line Added more comments to the new structseq repr code and implemented several of Neal's suggestions. ........
Diffstat (limited to 'Doc')
-rw-r--r--Doc/c-api/concrete.rst2
-rw-r--r--Doc/glossary.rst16
-rw-r--r--Doc/library/functions.rst15
-rw-r--r--Doc/library/sys.rst42
4 files changed, 63 insertions, 12 deletions
diff --git a/Doc/c-api/concrete.rst b/Doc/c-api/concrete.rst
index a2aaeea..cc5c9d5 100644
--- a/Doc/c-api/concrete.rst
+++ b/Doc/c-api/concrete.rst
@@ -433,7 +433,7 @@ Floating Point Objects
.. cfunction:: PyObject* PyFloat_GetInfo(void)
- Return a :ctype:`PyDictObject` object which contains information about the
+ Return a structseq instance which contains information about the
precision, minimum and maximum values of a float. It's a thin wrapper
around the header file :file:`float.h`.
diff --git a/Doc/glossary.rst b/Doc/glossary.rst
index 194fbd9..5c11ae0 100644
--- a/Doc/glossary.rst
+++ b/Doc/glossary.rst
@@ -329,11 +329,17 @@ Glossary
also :term:`immutable`.
named tuple
- A tuple subclass whose elements also are accessible as attributes via
- fixed names (the class name and field names are indicated in the
- individual documentation of a named tuple type, like ``TestResults(failed,
- attempted)``). Named tuple classes are created by
- :func:`collections.namedtuple`.
+ Any tuple-like class whose indexable fields are also accessible with
+ named attributes (for example, :func:`time.localtime` returns a
+ tuple-like object where the *year* is accessible either with an
+ index such as ``t[0]`` or with a named attribute like ``t.tm_year``).
+
+ A named tuple can be a built-in type such as :class:`time.struct_time`,
+ or it can be created with a regular class definition. A full featured
+ named tuple can also be created with the factory function
+ :func:`collections.namedtuple`. The latter approach automatically
+ provides extra features such as a self-documenting representation like
+ ``Employee(name='jones', title='programmer')``.
namespace
The place where a variable is stored. Namespaces are implemented as
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst
index e7add3a..731afb4 100644
--- a/Doc/library/functions.rst
+++ b/Doc/library/functions.rst
@@ -743,10 +743,17 @@ available. They are listed here in alphabetical order.
* 'U' universal newline mode (for backwards compatibility;
unnecessary in new code)
- Combine ``'b'`` with ``'r'``, ``'w'``, or ``'a'``, for binary
- mode, e.g., ``'rb'`` to open a file for reading in binary mode.
- Modes ``'r+'``, ``'w+'`` and ``'a+'`` open the file for updating (note
- that ``'w+'`` truncates the file).
+ The most commonly-used values of *mode* are ``'r'`` for reading, ``'w'`` for
+ writing (truncating the file if it already exists), and ``'a'`` for appending
+ (which on *some* Unix systems means that *all* writes append to the end of the
+ file regardless of the current seek position). If *mode* is omitted, it
+ defaults to ``'r'``. The default is to use text mode, which may convert
+ ``'\n'`` characters to a platform-specific representation on writing and back
+ on reading. Thus, when opening a binary file, you should append ``'b'`` to
+ the *mode* value to open the file in binary mode, which will improve
+ portability. (Appending ``'b'`` is useful even on systems that don't treat
+ binary and text files differently, where it serves as documentation.) See below
+ for more possible values of *mode*.
Python distinguishes between files opened in binary and text modes, even
when the underlying operating system doesn't. Files opened in binary
diff --git a/Doc/library/sys.rst b/Doc/library/sys.rst
index 85c592e..4ab3529 100644
--- a/Doc/library/sys.rst
+++ b/Doc/library/sys.rst
@@ -184,14 +184,52 @@ always available.
error occurs.
+.. data:: flags
+
+ The struct sequence *flags* exposes the status of command line flags. The
+ attributes are read only.
+
+ +------------------------------+------------------------------------------+
+ | attribute | flag |
+ +==============================+==========================================+
+ | :const:`debug` | -d |
+ +------------------------------+------------------------------------------+
+ | :const:`py3k_warning` | -3 |
+ +------------------------------+------------------------------------------+
+ | :const:`division_warning` | -Q |
+ +------------------------------+------------------------------------------+
+ | :const:`division_new` | -Qnew |
+ +------------------------------+------------------------------------------+
+ | :const:`inspect` | -i |
+ +------------------------------+------------------------------------------+
+ | :const:`interactive` | -i |
+ +------------------------------+------------------------------------------+
+ | :const:`optimize` | -O or -OO |
+ +------------------------------+------------------------------------------+
+ | :const:`dont_write_bytecode` | -B |
+ +------------------------------+------------------------------------------+
+ | :const:`no_site` | -S |
+ +------------------------------+------------------------------------------+
+ | :const:`ingnore_environment` | -E |
+ +------------------------------+------------------------------------------+
+ | :const:`tabcheck` | -t or -tt |
+ +------------------------------+------------------------------------------+
+ | :const:`verbose` | -v |
+ +------------------------------+------------------------------------------+
+ | :const:`unicode` | -U |
+ +------------------------------+------------------------------------------+
+
+ .. versionadded:: 2.6
+
+
.. data:: float_info
- A dict holding information about the float type. It contains low level
+ A structseq holding information about the float type. It contains low level
information about the precision and internal representation. Please study
your system's :file:`float.h` for more information.
+---------------------+--------------------------------------------------+
- | key | explanation |
+ | attribute | explanation |
+=====================+==================================================+
| :const:`epsilon` | Difference between 1 and the next representable |
| | floating point number |