9
9
.. hyperlink all the methods & functions.
10
10
11
11
.. T_STRING_INPLACE not described in main docs
12
- .. "Format String Syntax" in string.rst could use many more examples.
13
12
14
13
.. $Id$
15
14
Rules for maintenance:
@@ -57,12 +56,12 @@ release of 2.7 is currently scheduled for July 2010; the detailed
57
56
schedule is described in :pep: `373 `.
58
57
59
58
Numeric handling has been improved in many ways, for both
60
- floating-point numbers and for the :class: `Decimal ` class. There are
61
- some useful additions to the standard library, such as a greatly
62
- enhanced :mod: `unittest ` module, the :mod: `argparse ` module for
63
- parsing command-line options, convenient ordered-dictionary and
64
- :class: `Counter ` classes in the :mod: `collections ` module, and many
65
- other improvements.
59
+ floating-point numbers and for the :class: `~decimal. Decimal ` class.
60
+ There are some useful additions to the standard library, such as a
61
+ greatly enhanced :mod: `unittest ` module, the :mod: `argparse ` module
62
+ for parsing command-line options, convenient :class: ` ~collections.OrderedDict `
63
+ and :class: `~collections. Counter ` classes in the :mod: `collections ` module,
64
+ and many other improvements.
66
65
67
66
Python 2.7 is planned to be the last of the 2.x releases, so we worked
68
67
on making it a good release for the long term. To help with porting
@@ -117,8 +116,8 @@ Two consequences of the long-term significance of 2.7 are:
117
116
with responding to these concerns.
118
117
119
118
You can re-enable display of :exc: `DeprecationWarning ` messages by
120
- running Python with the :option: `-Wdefault ` (short form:
121
- :option: `-Wd `) switch, or by setting the :envvar: `PYTHONWARNINGS `
119
+ running Python with the :option: `-Wdefault <-W> ` (short form:
120
+ :option: `-Wd <-W> `) switch, or by setting the :envvar: `PYTHONWARNINGS `
122
121
environment variable to ``"default" `` (or ``"d" ``) before running
123
122
Python. Python code can also re-enable them
124
123
by calling ``warnings.simplefilter('default') ``.
@@ -135,7 +134,7 @@ for migrating to the 3.x series.
135
134
A partial list of 3.1 features that were backported to 2.7:
136
135
137
136
* The syntax for set literals (``{1,2,3} `` is a mutable set).
138
- * Dictionary and set comprehensions (``{ i: i*2 for i in range(3)} ``).
137
+ * Dictionary and set comprehensions (``{i: i*2 for i in range(3)} ``).
139
138
* Multiple context managers in a single :keyword: `with ` statement.
140
139
* A new version of the :mod: `io ` library, rewritten in C for performance.
141
140
* The ordered-dictionary type described in :ref: `pep-0372 `.
@@ -155,7 +154,7 @@ Other new Python3-mode warnings include:
155
154
* :func: `operator.isCallable ` and :func: `operator.sequenceIncludes `,
156
155
which are not supported in 3.x, now trigger warnings.
157
156
* The :option: `-3 ` switch now automatically
158
- enables the :option: `-Qwarn ` switch that causes warnings
157
+ enables the :option: `-Qwarn <-Q> ` switch that causes warnings
159
158
about using classic division with integers and long integers.
160
159
161
160
@@ -390,7 +389,8 @@ standard input or output.
390
389
391
390
.. seealso ::
392
391
393
- `argparse module documentation <http://docs.python.org/dev/library/argparse.html >`__
392
+ `argparse documentation <http://docs.python.org/dev/library/argparse.html >`__
393
+ The documentation page of the argparse module.
394
394
395
395
`Upgrading optparse code to use argparse <http://docs.python.org/dev/library/argparse.html#upgrading-optparse-code >`__
396
396
Part of the Python documentation, describing how to convert
@@ -402,8 +402,6 @@ standard input or output.
402
402
PEP 391: Dictionary-Based Configuration For Logging
403
403
====================================================
404
404
405
- .. XXX not documented in library reference yet; add link here once it's added.
406
-
407
405
The :mod: `logging ` module is very flexible; applications can define
408
406
a tree of logging subsystems, and each logger in this tree can filter
409
407
out certain messages, format them differently, and direct messages to
@@ -412,21 +410,21 @@ a varying number of handlers.
412
410
All this flexibility can require a lot of configuration. You can
413
411
write Python statements to create objects and set their properties,
414
412
but a complex set-up requires verbose but boring code.
415
- :mod: `logging ` also supports a :func: `~logging.config. fileConfig `
413
+ :mod: `logging ` also supports a :func: `~logging.fileConfig `
416
414
function that parses a file, but the file format doesn't support
417
415
configuring filters, and it's messier to generate programmatically.
418
416
419
- Python 2.7 adds a :func: `~logging.config. dictConfig ` function that
417
+ Python 2.7 adds a :func: `~logging.dictConfig ` function that
420
418
uses a dictionary to configure logging. There are many ways to
421
419
produce a dictionary from different sources: construct one with code;
422
420
parse a file containing JSON; or use a YAML parsing library if one is
423
- installed.
421
+ installed. For more information see :ref: ` logging-config-api `.
424
422
425
423
The following example configures two loggers, the root logger and a
426
- logger named "network". Messages sent to the root logger will be
424
+ logger named "network". Messages sent to the root logger will be
427
425
sent to the system log using the syslog protocol, and messages
428
426
to the "network" logger will be written to a :file: `network.log ` file
429
- that will be rotated once the log reaches 1Mb .
427
+ that will be rotated once the log reaches 1MB .
430
428
431
429
::
432
430
@@ -445,7 +443,7 @@ that will be rotated once the log reaches 1Mb.
445
443
'filename': '/logs/network.log',
446
444
'formatter': 'standard',
447
445
'level': 'INFO',
448
- 'maxBytes': 1024*1024 },
446
+ 'maxBytes': 1000000 },
449
447
'syslog': {'class': 'logging.handlers.SysLogHandler',
450
448
'formatter': 'standard',
451
449
'level': 'ERROR'}},
@@ -483,16 +481,19 @@ implemented by Vinay Sajip, are:
483
481
for UDP or :const: `socket.SOCK_STREAM ` for TCP. The default
484
482
protocol remains UDP.
485
483
486
- * :class: `Logger ` instances gained a :meth: `getChild ` method that retrieves a
487
- descendant logger using a relative path. For example,
488
- once you retrieve a logger by doing ``log = getLogger('app') ``,
484
+ * :class: `~logging. Logger ` instances gained a :meth: `~logging.Logger. getChild `
485
+ method that retrieves a descendant logger using a relative path.
486
+ For example, once you retrieve a logger by doing ``log = getLogger('app') ``,
489
487
calling ``log.getChild('network.listen') `` is equivalent to
490
488
``getLogger('app.network.listen') ``.
491
489
492
- * The :class: `LoggerAdapter ` class gained a :meth: `isEnabledFor ` method
493
- that takes a *level * and returns whether the underlying logger would
490
+ * The :class: `~logging.LoggerAdapter ` class gained a
491
+ :meth: `~logging.LoggerAdapter.isEnabledFor ` method that takes a
492
+ *level * and returns whether the underlying logger would
494
493
process a message of that level of importance.
495
494
495
+ .. XXX: Logger objects don't have a class declaration so the link don't work
496
+
496
497
.. seealso ::
497
498
498
499
:pep: `391 ` - Dictionary-Based Configuration For Logging
@@ -501,14 +502,15 @@ implemented by Vinay Sajip, are:
501
502
PEP 3106: Dictionary Views
502
503
====================================================
503
504
504
- The dictionary methods :meth: `keys `, :meth: `values `, and :meth: ` items `
505
- are different in Python 3.x. They return an object called a :dfn: ` view `
506
- instead of a fully materialized list.
505
+ The dictionary methods :meth: `~dict. keys `, :meth: `~dict. values `, and
506
+ :meth: ` ~dict.items ` are different in Python 3.x. They return an object
507
+ called a :dfn: ` view ` instead of a fully materialized list.
507
508
508
- It's not possible to change the return values of :meth: `keys `,
509
- :meth: `values `, and :meth: `items ` in Python 2.7 because too much code
510
- would break. Instead the 3.x versions were added under the new names
511
- :meth: `viewkeys `, :meth: `viewvalues `, and :meth: `viewitems `.
509
+ It's not possible to change the return values of :meth: `~dict.keys `,
510
+ :meth: `~dict.values `, and :meth: `~dict.items ` in Python 2.7 because
511
+ too much code would break. Instead the 3.x versions were added
512
+ under the new names :meth: `~dict.viewkeys `, :meth: `~dict.viewvalues `,
513
+ and :meth: `~dict.viewitems `.
512
514
513
515
::
514
516
@@ -550,8 +552,8 @@ over the view::
550
552
RuntimeError: dictionary changed size during iteration
551
553
552
554
You can use the view methods in Python 2.x code, and the 2to3
553
- converter will change them to the standard :meth: `keys `,
554
- :meth: `values `, and :meth: `items ` methods.
555
+ converter will change them to the standard :meth: `~dict. keys `,
556
+ :meth: `~dict. values `, and :meth: `~dict. items ` methods.
555
557
556
558
.. seealso ::
557
559
@@ -624,7 +626,7 @@ Some smaller changes made to the core Python language are:
624
626
``{} `` continues to represent an empty dictionary; use
625
627
``set() `` for an empty set.
626
628
627
- >>> {1 ,2 , 3 , 4 , 5 }
629
+ >>> {1 , 2 , 3 , 4 , 5 }
628
630
set([1, 2, 3, 4, 5])
629
631
>>> set () # empty set
630
632
set([])
@@ -794,7 +796,7 @@ Some smaller changes made to the core Python language are:
794
796
``None `` as its first argument. (Fixed by Georg Brandl;
795
797
:issue: `4759 `.)
796
798
797
- .. bytearray doesn't seem to be documented
799
+ .. XXX bytearray doesn't seem to be documented
798
800
799
801
* When using ``@classmethod `` and ``@staticmethod `` to wrap
800
802
methods as class or static methods, the wrapper object now
@@ -1054,7 +1056,7 @@ changes, or look through the Subversion logs for all the details.
1054
1056
:meth: `~collections.deque.count ` method that returns the number of
1055
1057
contained elements equal to the supplied argument *x *, and a
1056
1058
:meth: `~collections.deque.reverse ` method that reverses the elements
1057
- of the deque in-place. :class: `deque ` also exposes its maximum
1059
+ of the deque in-place. :class: `~collections. deque ` also exposes its maximum
1058
1060
length as the read-only :attr: `~collections.deque.maxlen ` attribute.
1059
1061
(Both features added by Raymond Hettinger.)
1060
1062
@@ -1135,15 +1137,14 @@ changes, or look through the Subversion logs for all the details.
1135
1137
``Decimal('0.1000000000000000055511151231257827021181583404541015625') ``.
1136
1138
(Implemented by Raymond Hettinger; :issue: `4796 `.)
1137
1139
1138
- Comparing instances of :class: `Decimal ` with floating-point
1140
+ Comparing instances of :class: `~decimal. Decimal ` with floating-point
1139
1141
numbers now produces sensible results based on the numeric values
1140
1142
of the operands. Previously such comparisons would fall back to
1141
1143
Python's default rules for comparing objects, which produced arbitrary
1142
1144
results based on their type. Note that you still cannot combine
1143
1145
:class: `Decimal ` and floating-point in other operations such as addition,
1144
1146
since you should be explicitly choosing how to convert between float and
1145
- :class: `Decimal `.
1146
- (Fixed by Mark Dickinson; :issue: `2531 `.)
1147
+ :class: `~decimal.Decimal `. (Fixed by Mark Dickinson; :issue: `2531 `.)
1147
1148
1148
1149
The constructor for :class: `~decimal.Decimal ` now accepts
1149
1150
floating-point numbers (added by Raymond Hettinger; :issue: `8257 `)
@@ -1195,8 +1196,8 @@ changes, or look through the Subversion logs for all the details.
1195
1196
1196
1197
Ordering comparisons (``< ``, ``<= ``, ``> ``, ``>= ``) between
1197
1198
fractions and complex numbers now raise a :exc: `TypeError `.
1198
- This fixes an oversight, making the :class: `Fraction ` match the other
1199
- numeric types.
1199
+ This fixes an oversight, making the :class: `~fractions. Fraction `
1200
+ match the other numeric types.
1200
1201
1201
1202
.. revision 79455
1202
1203
@@ -1210,15 +1211,15 @@ changes, or look through the Subversion logs for all the details.
1210
1211
uploads thanks to an added *rest * parameter (patch by Pablo Mouzo;
1211
1212
:issue: `6845 `.)
1212
1213
1213
- * New class decorator: :func: `total_ordering ` in the :mod: `functools `
1214
+ * New class decorator: :func: `~functools. total_ordering ` in the :mod: `functools `
1214
1215
module takes a class that defines an :meth: `__eq__ ` method and one of
1215
1216
:meth: `__lt__ `, :meth: `__le__ `, :meth: `__gt__ `, or :meth: `__ge__ `,
1216
1217
and generates the missing comparison methods. Since the
1217
1218
:meth: `__cmp__ ` method is being deprecated in Python 3.x,
1218
1219
this decorator makes it easier to define ordered classes.
1219
1220
(Added by Raymond Hettinger; :issue: `5479 `.)
1220
1221
1221
- New function: :func: `cmp_to_key ` will take an old-style comparison
1222
+ New function: :func: `~functools. cmp_to_key ` will take an old-style comparison
1222
1223
function that expects two arguments and return a new callable that
1223
1224
can be used as the *key * parameter to functions such as
1224
1225
:func: `sorted `, :func: `min ` and :func: `max `, etc. The primary
@@ -1345,7 +1346,7 @@ changes, or look through the Subversion logs for all the details.
1345
1346
with any object literal that decodes to a list of pairs.
1346
1347
(Contributed by Raymond Hettinger; :issue: `5381 `.)
1347
1348
1348
- * The :mod: `mailbox ` module's :class: `Maildir ` class now records the
1349
+ * The :mod: `mailbox ` module's :class: `~mailbox. Maildir ` class now records the
1349
1350
timestamp on the directories it reads, and only re-reads them if the
1350
1351
modification time has subsequently changed. This improves
1351
1352
performance by avoiding unneeded directory scans. (Fixed by
@@ -1466,10 +1467,10 @@ changes, or look through the Subversion logs for all the details.
1466
1467
defaults to False; if overridden to be True,
1467
1468
new request connections will have the TCP_NODELAY option set to
1468
1469
prevent buffering many small sends into a single TCP packet.
1469
- The :attr: `~SocketServer.TCPServer .timeout ` class attribute can hold
1470
+ The :attr: `~SocketServer.BaseServer .timeout ` class attribute can hold
1470
1471
a timeout in seconds that will be applied to the request socket; if
1471
- no request is received within that time, :meth: `handle_timeout `
1472
- will be called and :meth: `handle_request ` will return.
1472
+ no request is received within that time, :meth: `~SocketServer.BaseServer. handle_timeout `
1473
+ will be called and :meth: `~SocketServer.BaseServer. handle_request ` will return.
1473
1474
(Contributed by Kristján Valur Jónsson; :issue: `6192 ` and :issue: `6267 `.)
1474
1475
1475
1476
* Updated module: the :mod: `sqlite3 ` module has been updated to
@@ -1479,7 +1480,7 @@ changes, or look through the Subversion logs for all the details.
1479
1480
and then call :meth: `~sqlite3.Connection.load_extension ` to load a particular shared library.
1480
1481
(Updated by Gerhard Häring.)
1481
1482
1482
- * The :mod: `ssl ` module's :class: `ssl.SSLSocket ` objects now support the
1483
+ * The :mod: `ssl ` module's :class: `~ ssl.SSLSocket ` objects now support the
1483
1484
buffer API, which fixed a test suite failure (fix by Antoine Pitrou;
1484
1485
:issue: `7133 `) and automatically set
1485
1486
OpenSSL's :cmacro: `SSL_MODE_AUTO_RETRY `, which will prevent an error
@@ -1535,7 +1536,7 @@ changes, or look through the Subversion logs for all the details.
1535
1536
on receiving an :const: `EINTR ` signal. (Reported by several people; final
1536
1537
patch by Gregory P. Smith in :issue: `1068268 `.)
1537
1538
1538
- * New function: :func: `~symtable.is_declared_global ` in the :mod: `symtable ` module
1539
+ * New function: :func: `~symtable.Symbol. is_declared_global ` in the :mod: `symtable ` module
1539
1540
returns true for variables that are explicitly declared to be global,
1540
1541
false for ones that are implicitly global.
1541
1542
(Contributed by Jeremy Hylton.)
@@ -1716,7 +1717,7 @@ Some of the functions in the module are:
1716
1717
Makefile and the :file: `pyconfig.h ` file.
1717
1718
* :func: `~sysconfig.get_config_vars ` returns a dictionary containing
1718
1719
all of the configuration variables.
1719
- * :func: `~sysconfig.getpath ` returns the configured path for
1720
+ * :func: `~sysconfig.get_path ` returns the configured path for
1720
1721
a particular type of module: the standard library,
1721
1722
site-specific modules, platform-specific modules, etc.
1722
1723
* :func: `~sysconfig.is_python_build ` returns true if you're running a
@@ -1778,7 +1779,7 @@ any importable test files named ``test*.py``::
1778
1779
Consult the :mod: `unittest ` module documentation for more details.
1779
1780
(Developed in :issue: `6001 `.)
1780
1781
1781
- The :func: `main ` function supports some other new options:
1782
+ The :func: `~unittest. main ` function supports some other new options:
1782
1783
1783
1784
* :option: `-b ` or :option: `--buffer ` will buffer the standard output
1784
1785
and standard error streams during each test. If the test passes,
@@ -1796,7 +1797,7 @@ The :func:`main` function supports some other new options:
1796
1797
being tested or the tests being run have defined a signal handler of
1797
1798
their own, by noticing that a signal handler was already set and
1798
1799
calling it. If this doesn't work for you, there's a
1799
- :func: `removeHandler ` decorator that can be used to mark tests that
1800
+ :func: `~unittest. removeHandler ` decorator that can be used to mark tests that
1800
1801
should have the control-C handling disabled.
1801
1802
1802
1803
* :option: `-f ` or :option: `--failfast ` makes
@@ -1923,7 +1924,7 @@ GvR worked on merging them into Python's version of :mod:`unittest`.
1923
1924
1924
1925
:func: `unittest.main ` now takes an optional ``exit `` argument. If
1925
1926
False, :func: `~unittest.main ` doesn't call :func: `sys.exit `, allowing
1926
- :func: `main ` to be used from the interactive interpreter.
1927
+ :func: `~unittest. main ` to be used from the interactive interpreter.
1927
1928
(Contributed by J. Pablo Fernández; :issue: `3379 `.)
1928
1929
1929
1930
:class: `~unittest.TestResult ` has new :meth: `~unittest.TestResult.startTestRun ` and
@@ -2117,7 +2118,7 @@ Changes to Python's build process and to the C API include:
2117
2118
:cmacro: `Py_ISSPACE `,
2118
2119
:cmacro: `Py_ISUPPER `,
2119
2120
:cmacro: `Py_ISXDIGIT `,
2120
- and :cmacro: `Py_TOLOWER `, :cmacro: `Py_TOUPPER `.
2121
+ :cmacro: `Py_TOLOWER `, and :cmacro: `Py_TOUPPER `.
2121
2122
All of these functions are analogous to the C
2122
2123
standard macros for classifying characters, but ignore the current
2123
2124
locale setting, because in
@@ -2263,11 +2264,11 @@ Port-Specific Changes: Windows
2263
2264
(Contributed by David Cournapeau; :issue: `4365 `.)
2264
2265
2265
2266
* The :mod: `_winreg ` module for accessing the registry now implements
2266
- the :func: `CreateKeyEx ` and :func: `DeleteKeyEx ` functions, extended
2267
- versions of previously-supported functions that take several extra
2268
- arguments. The :func: `DisableReflectionKey `,
2269
- :func: `EnableReflectionKey `, and :func: `QueryReflectionKey ` were also
2270
- tested and documented.
2267
+ the :func: `~_winreg. CreateKeyEx ` and :func: `~_winreg. DeleteKeyEx `
2268
+ functions, extended versions of previously-supported functions that
2269
+ take several extra arguments. The :func: `~_winreg. DisableReflectionKey `,
2270
+ :func: `~_winreg. EnableReflectionKey `, and :func: `~_winreg. QueryReflectionKey `
2271
+ were also tested and documented.
2271
2272
(Implemented by Brian Curtin: :issue: `7347 `.)
2272
2273
2273
2274
* The new :cfunc: `_beginthreadex ` API is used to start threads, and
@@ -2384,20 +2385,20 @@ that may require changes to your code:
2384
2385
2385
2386
In the standard library:
2386
2387
2387
- * Operations with :class: `datetime ` instances that resulted in a year
2388
+ * Operations with :class: `~datetime. datetime ` instances that resulted in a year
2388
2389
falling outside the supported range didn't always raise
2389
2390
:exc: `OverflowError `. Such errors are now checked more carefully
2390
2391
and will now raise the exception. (Reported by Mark Leander, patch
2391
2392
by Anand B. Pillai and Alexander Belopolsky; :issue: `7150 `.)
2392
2393
2393
- * When using :class: `Decimal ` instances with a string's
2394
+ * When using :class: `~decimal. Decimal ` instances with a string's
2394
2395
:meth: `format ` method, the default alignment was previously
2395
2396
left-alignment. This has been changed to right-alignment, which might
2396
2397
change the output of your programs.
2397
2398
(Changed by Mark Dickinson; :issue: `6857 `.)
2398
2399
2399
2400
Comparisons involving a signaling NaN value (or ``sNAN ``) now signal
2400
- :const: `InvalidOperation ` instead of silently returning a true or
2401
+ :const: `~decimal. InvalidOperation ` instead of silently returning a true or
2401
2402
false value depending on the comparison operator. Quiet NaN values
2402
2403
(or ``NaN ``) are now hashable. (Fixed by Mark Dickinson;
2403
2404
:issue: `7279 `.)
@@ -2408,7 +2409,7 @@ In the standard library:
2408
2409
or comment (which looks like `<!-- comment --> `).
2409
2410
(Patch by Neil Muller; :issue: `2746 `.)
2410
2411
2411
- * The :meth: `readline ` method of :class: `StringIO ` objects now does
2412
+ * The :meth: `~StringIO.StringIO. readline ` method of :class: `~StringIO. StringIO ` objects now does
2412
2413
nothing when a negative length is requested, as other file-like
2413
2414
objects do. (:issue: `7348 `).
2414
2415
0 commit comments