40
40
* Credit the author of a patch or bugfix. Just the name is
41
41
sufficient; the e-mail address isn't necessary.
43
* It's helpful to add the bug/patch number in an parenthetical
43
* It's helpful to add the bug/patch number in a parenthetical comment.
45
45
XXX Describe the transmogrify() function added to the socket
47
47
(Contributed by P.Y. Developer; :issue:`12345`.)
49
This saves the maintainer the effort of going through the SVN logs
49
This saves the maintainer some effort going through the SVN logs
50
50
when researching a change.
52
This article explains the new features in Python 2.6. No release date for
53
Python 2.6 has been set; it will probably be released in mid 2008.
52
This article explains the new features in Python 2.6. The release
53
schedule is described in :pep:`361`; currently the final release is
54
scheduled for September 3 2008.
55
56
This article doesn't attempt to provide a complete specification of
56
57
the new features, but instead provides a convenient overview. For
57
58
full details, you should refer to the documentation for Python 2.6. If
58
you want to understand the complete implementation and design
59
rationale, refer to the PEP for a particular new feature. For smaller
60
changes, this edition of "What's New in Python" links to the bug/patch
61
item for each change whenever possible.
59
you want to understand the rationale for the design and
60
implementation, refer to the PEP for a particular new feature.
61
Whenever possible, "What's New in Python" links to the bug/patch item
63
64
.. Compare with previous release in 2 - 3 sentences here.
64
65
add hyperlink when the documentation becomes available online.
137
138
<http://www.atlassian.com/software/jira/>`__,
138
139
`Launchpad <http://www.launchpad.net>`__,
139
140
`Roundup <http://roundup.sourceforge.net/>`__, and
140
Trac <http://trac.edgewall.org/>`__.
141
`Trac <http://trac.edgewall.org/>`__.
141
142
The committee eventually settled on Jira
142
143
and Roundup as the two candidates. Jira is a commercial product that
143
144
offers a no-cost hosted instance to free-software projects; Roundup
171
172
Roundup downloads and documentation.
174
New Documentation Format: ReStructuredText Using Sphinx
175
New Documentation Format: reStructuredText Using Sphinx
175
176
-----------------------------------------------------------
177
178
Since the Python project's inception around 1989, the documentation
482
483
.. ======================================================================
489
=====================================================
491
When you run Python, the module search page ``sys.modules`` usually
492
includes a directory whose path ends in ``"site-packages"``. This
493
directory is intended to hold locally-installed packages available to
494
all users on a machine or using a particular site installation.
496
Python 2.6 introduces a convention for user-specific site directories.
501
PEP written by XXX; implemented by Christian Heimes.
487
PEP 370: Per-user ``site-packages`` Directory
488
=====================================================
490
When you run Python, the module search path ``sys.modules`` usually
491
includes a directory whose path ends in ``"site-packages"``. This
492
directory is intended to hold locally-installed packages available to
493
all users on a machine or using a particular site installation.
495
Python 2.6 introduces a convention for user-specific site directories.
496
The directory varies depending on the platform:
498
* Unix and MacOS: :file:`~/.local/`
499
* Windows: :file:`%APPDATA%/Python`
501
Within this directory, there will be version-specific subdirectories,
502
such as :file:`lib/python2.6/site-packages` on Unix/MacOS and
503
:file:`Python26/site-packages` on Windows.
505
If you don't like the default directory, it can be overridden by an
506
environment variable. :envvar:`PYTHONUSERBASE` sets the root
507
directory used for all Python versions supporting this feature. On
508
Windows, the directory for application-specific data can be changed by
509
setting the :envvar:`APPDATA` environment variable. You can also
510
modify the :file:`site.py` file for your Python installation.
512
The feature can be disabled entirely by running Python with the
513
:option:`-s` option or setting the :envvar:`PYTHONNOUSERSITE`
514
environment variable.
518
:pep:`370` - Per-user ``site-packages`` Directory
519
PEP written and implemented by Christian Heimes.
504
522
.. ======================================================================
596
614
A variety of presentation types are available. Consult the 2.6
597
documentation for a complete list (XXX add link, once it's in the 2.6
598
docs), but here's a sample::
615
documentation for a :ref:`complete list <formatstrings>`; here's a sample::
600
617
'b' - Binary. Outputs the number in base 2.
601
618
'c' - Character. Converts the integer to the corresponding
609
626
'g' - General format. This prints the number as a fixed-point
610
627
number, unless the number is too large, in which case
611
628
it switches to 'e' exponent notation.
612
'n' - Number. This is the same as 'g', except that it uses the
613
current locale setting to insert the appropriate
614
number separator characters.
629
'n' - Number. This is the same as 'g' (for floats) or 'd' (for
630
integers), except that it uses the current locale setting to
631
insert the appropriate number separator characters.
615
632
'%' - Percentage. Multiplies the number by 100 and displays
616
633
in fixed ('f') format, followed by a percent sign.
735
752
There's also a ``__future__`` import that causes all string literals
736
753
to become Unicode strings. This means that ``\u`` escape sequences
737
can be used to include Unicode characters.
754
can be used to include Unicode characters::
739
757
from __future__ import unicode_literals
1445
1465
As usual, Python's standard library received a number of enhancements and bug
1446
1466
fixes. Here's a partial list of the most notable changes, sorted alphabetically
1447
1467
by module name. Consult the :file:`Misc/NEWS` file in the source tree for a more
1448
complete list of changes, or look through the CVS logs for all the details.
1468
complete list of changes, or look through the Subversion logs for all the
1471
* (3.0-warning mode) Python 3.0 will feature a reorganized standard
1472
library; many outdated modules are being dropped,
1473
and some modules are being renamed or moved into packages.
1474
Python 2.6 running in 3.0-warning mode will warn about these modules
1475
when they are imported.
1477
The modules that have been renamed are:
1479
* :mod:`ConfigParser` has become :mod:`configparser`.
1480
* :mod:`copy_reg` has become :mod:`copyreg`.
1481
* :mod:`htmlentitydefs` has become :mod:`html.entities`.
1482
* :mod:`HTMLParser` has become :mod:`html.parser`.
1483
* :mod:`repr` (the module) has become :mod:`reprlib`.
1484
* :mod:`SocketServer` has become :mod:`socketserver`.
1485
* :mod:`Tkinter` has become the :mod:`tkinter` package.
1486
* :mod:`Queue` has become :mod:`queue`.
1488
The list of deprecated modules is:
1490
:mod:`bgenlocations`,
1492
:mod:`bundlebuilder`,
1498
:mod:`gensuitemodule`,
1502
:mod:`linuxaudiodev`,
1510
:mod:`test.testall`,
1513
Various MacOS modules have been removed:
1514
:mod:`_builtinSuites`,
1519
:mod:`appletrawmain`,
1520
:mod:`appletrunner`,
1521
:mod:`argvemulator`,
1543
:mod:`OSATerminology`,
1545
:mod:`PixMapWrapper`,
1547
:mod:`SystemEvents`,
1549
:mod:`terminalcommand`.
1551
A number of old IRIX-specific modules were deprecated:
1555
:mod:`CL` and :mod:`cl`,
1559
:mod:`FL` and :mod:`fl`,
1564
:mod:`GL` and :mod:`gl`,
1570
:mod:`SV` and :mod:`sv`,
1450
1575
* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
1451
1576
available, instead of restricting itself to protocol 1.
1691
1816
``permutations(iter[, r])`` returns all the permutations of length *r* of
1692
1817
the iterable's elements. If *r* is not specified, it will default to the
1693
number of elements produced by the iterable.
1818
number of elements produced by the iterable. ::
1695
1820
itertools.permutations([1,2,3,4], 2) ->
1696
1821
[(1, 2), (1, 3), (1, 4),
1728
1853
the forward search.
1729
1854
(Contributed by John Lenton.)
1731
* (3.0-warning mode) The :mod:`new` module has been removed from
1732
Python 3.0. Importing it therefore triggers a warning message.
1734
1856
* The :mod:`operator` module gained a
1735
1857
:func:`methodcaller` function that takes a name and an optional
1736
1858
set of arguments, returning a callable that will call
1841
1963
used to hold character data.
1842
1964
(Contributed by Achim Gaedke; :issue:`1137`.)
1844
* The :mod:`Queue` module now provides queue classes that retrieve entries
1966
* The :mod:`queue` module now provides queue classes that retrieve entries
1845
1967
in different orders. The :class:`PriorityQueue` class stores
1846
1968
queued items in a heap and retrieves them in priority order,
1847
1969
and :class:`LifoQueue` retrieves the most recently added entries first,
1945
2067
and connects to it using an optional timeout value, returning
1946
2068
the connected socket object.
1948
* The base classes in the :mod:`SocketServer` module now support
2070
* The base classes in the :mod:`socketserver` module now support
1949
2071
calling a :meth:`handle_timeout` method after a span of inactivity
1950
2072
specified by the server's :attr:`timeout` attribute. (Contributed
1951
2073
by Michael Pomraning.) The :meth:`serve_forever` method
2102
2224
(Added by Facundo Batista.)
2104
* The XML-RPC classes :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
2226
* The :mod:`warnings` module's :func:`formatwarning` and :func:`showwarning`
2227
gained an optional *line* argument that can be used to supply the
2228
line of source code. (Added as part of :issue:`1631171`, which re-implemented
2229
part of the :mod:`warnings` module in C code.)
2231
* The XML-RPC :class:`SimpleXMLRPCServer` and :class:`DocXMLRPCServer`
2105
2232
classes can now be prevented from immediately opening and binding to
2106
2233
their socket by passing True as the ``bind_and_activate``
2107
2234
constructor parameter. This can be used to modify the instance's
2142
2269
(Contributed by Alan McIntyre; :issue:`467924`.)
2271
Also, :mod:`zipfile` now supports using Unicode filenames
2272
for archived files. (Contributed by Alexey Borzenkov; :issue:`1734346`.)
2144
2274
.. ======================================================================
2145
2275
.. whole new modules get described in subsections here
2277
The :mod:`json` module
2278
----------------------
2280
The new :mod:`json` module supports the encoding and decoding of Python types in
2281
JSON (Javascript Object Notation). JSON is a lightweight interchange format
2282
often used in web applications. For more information about JSON, see
2283
http://www.json.org.
2285
:mod:`json` comes with support for decoding and encoding most builtin Python
2286
types. The following example encodes and decodes a dictionary::
2289
>>> data = {"spam" : "foo", "parrot" : 42}
2290
>>> in_json = json.dumps(data) # Encode the data
2292
'{"parrot": 42, "spam": "foo"}'
2293
>>> json.loads(in_json) # Decode into a Python object
2294
{"spam" : "foo", "parrot" : 42}
2296
It is also possible to write your own decoders and encoders to support more
2297
types. Pretty-printing of the JSON strings is also supported.
2299
:mod:`json` (originally called simplejson) was written by Bob Ippolito.
2147
2302
Improved SSL Support
2148
2303
--------------------------------------------------
2159
2314
To use the new module, first you must create a TCP connection in the
2160
2315
usual way and then pass it to the :func:`ssl.wrap_socket` function.
2161
XXX describe parameters.
2163
XXX Can specify if certificate is required, and obtain certificate info
2164
by calling getpeercert method.
2166
XXX Certain features require the OpenSSL package to be installed, notably
2167
the 'openssl' binary.
2316
It's possible to specify whether a certificate is required, and to
2317
obtain certificate info by calling the :meth:`getpeercert` method.
2171
SSL module documentation.
2321
The documentation for the :mod:`ssl` module.
2174
2324
.. ======================================================================
2322
2472
Port-Specific Changes: Windows
2323
2473
-----------------------------------
2475
* The support for Windows 95, 98, ME and NT4 has been dropped.
2476
Python 2.6 requires at least Windows 2000 SP4.
2325
2478
* The :mod:`msvcrt` module now supports
2326
2479
both the normal and wide char variants of the console I/O
2327
2480
API. The :func:`getwch` function reads a keypress and returns a Unicode