~pythonregexp2.7/python/issue2636-06

« back to all changes in this revision

Viewing changes to Doc/whatsnew/2.6.rst

  • Committer: Jeffrey C. "The TimeHorse" Jacobs
  • Date: 2008-05-24 16:10:37 UTC
  • mfrom: (39025.1.6 Regexp-2.6)
  • Revision ID: darklord@timehorse.com-20080524161037-oa3fo9iyz4fj02do
Merged in changes from the core Regexp branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
   * Credit the author of a patch or bugfix.   Just the name is
41
41
   sufficient; the e-mail address isn't necessary.
42
42
   
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.
44
44
   
45
45
   XXX Describe the transmogrify() function added to the socket
46
46
   module.
47
47
   (Contributed by P.Y. Developer; :issue:`12345`.)
48
48
   
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.
51
51
 
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.
54
55
 
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
 
62
for each change.
62
63
 
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.
172
173
 
173
174
 
174
 
New Documentation Format: ReStructuredText Using Sphinx
 
175
New Documentation Format: reStructuredText Using Sphinx
175
176
-----------------------------------------------------------
176
177
 
177
178
Since the Python project's inception around 1989, the documentation
481
482
 
482
483
.. ======================================================================
483
484
 
484
 
.. ::
485
 
 
486
 
    .. _pep-0370:
487
 
 
488
 
    PEP 370: XXX
489
 
    =====================================================
490
 
 
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.
495
 
 
496
 
    Python 2.6 introduces a convention for user-specific site directories.
497
 
 
498
 
    .. seealso::
499
 
 
500
 
       :pep:`370` - XXX
501
 
         PEP written by XXX; implemented by Christian Heimes.
 
485
.. _pep-0370:
 
486
 
 
487
PEP 370: Per-user ``site-packages`` Directory
 
488
=====================================================
 
489
 
 
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.
 
494
 
 
495
Python 2.6 introduces a convention for user-specific site directories.
 
496
The directory varies depending on the platform:
 
497
 
 
498
* Unix and MacOS: :file:`~/.local/`
 
499
* Windows: :file:`%APPDATA%/Python`
 
500
 
 
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.
 
504
 
 
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.
 
511
 
 
512
The feature can be disabled entirely by running Python with the
 
513
:option:`-s` option or setting the :envvar:`PYTHONNOUSERSITE`
 
514
environment variable.
 
515
 
 
516
.. seealso::
 
517
 
 
518
   :pep:`370` - Per-user ``site-packages`` Directory
 
519
     PEP written and implemented by Christian Heimes.
502
520
 
503
521
  
504
522
.. ======================================================================
594
612
    '3.750000e+00'
595
613
 
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::
599
616
 
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.
617
634
 
734
751
 
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::
 
755
 
738
756
 
739
757
    from __future__ import unicode_literals
740
758
 
744
762
    print len(s)               # 12 Unicode characters
745
763
 
746
764
 
 
765
 
747
766
.. seealso::
748
767
 
749
768
   :pep:`3112` - Bytes literals in Python 3000
1208
1227
long time.  This implementation was significantly updated by Jeffrey
1209
1228
Yasskin.
1210
1229
 
 
1230
 
1211
1231
Other Language Changes
1212
1232
======================
1213
1233
 
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
 
1469
details.
 
1470
 
 
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.
 
1476
 
 
1477
  The modules that have been renamed are:
 
1478
 
 
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`.
 
1487
 
 
1488
  The list of deprecated modules is:
 
1489
  :mod:`audiodev`,
 
1490
  :mod:`bgenlocations`,
 
1491
  :mod:`buildtools`,
 
1492
  :mod:`bundlebuilder`,
 
1493
  :mod:`Canvas`,
 
1494
  :mod:`compiler`,
 
1495
  :mod:`dircache`,
 
1496
  :mod:`dl`,
 
1497
  :mod:`fpformat`,
 
1498
  :mod:`gensuitemodule`,
 
1499
  :mod:`ihooks`,
 
1500
  :mod:`imageop`,
 
1501
  :mod:`imgfile`,
 
1502
  :mod:`linuxaudiodev`,
 
1503
  :mod:`mhlib`,
 
1504
  :mod:`multifile`,
 
1505
  :mod:`new`,
 
1506
  :mod:`popen2`,
 
1507
  :mod:`pure`,
 
1508
  :mod:`statvfs`,
 
1509
  :mod:`sunaudiodev`,
 
1510
  :mod:`test.testall`,
 
1511
  :mod:`toaiff`.
 
1512
 
 
1513
  Various MacOS modules have been removed:
 
1514
  :mod:`_builtinSuites`,
 
1515
  :mod:`aepack`,
 
1516
  :mod:`aetools`,
 
1517
  :mod:`aetypes`,
 
1518
  :mod:`applesingle`,
 
1519
  :mod:`appletrawmain`,
 
1520
  :mod:`appletrunner`,
 
1521
  :mod:`argvemulator`,
 
1522
  :mod:`Audio_mac`,
 
1523
  :mod:`autoGIL`,
 
1524
  :mod:`Carbon`,
 
1525
  :mod:`cfmfile`,
 
1526
  :mod:`CodeWarrior`,
 
1527
  :mod:`ColorPicker`,
 
1528
  :mod:`EasyDialogs`,
 
1529
  :mod:`Explorer`,
 
1530
  :mod:`Finder`,
 
1531
  :mod:`FrameWork`,
 
1532
  :mod:`findertools`,
 
1533
  :mod:`ic`,
 
1534
  :mod:`icglue`,
 
1535
  :mod:`icopen`,
 
1536
  :mod:`macerrors`,
 
1537
  :mod:`MacOS`,
 
1538
  :mod:`macostools`,
 
1539
  :mod:`macresource`,
 
1540
  :mod:`MiniAEFrame`,
 
1541
  :mod:`Nav`,
 
1542
  :mod:`Netscape`,
 
1543
  :mod:`OSATerminology`,
 
1544
  :mod:`pimp`,
 
1545
  :mod:`PixMapWrapper`,
 
1546
  :mod:`StdSuites`,
 
1547
  :mod:`SystemEvents`,
 
1548
  :mod:`Terminal`,
 
1549
  :mod:`terminalcommand`.
 
1550
 
 
1551
  A number of old IRIX-specific modules were deprecated:
 
1552
  :mod:`cd`,
 
1553
  :mod:`cddb`,
 
1554
  :mod:`cdplayer`,
 
1555
  :mod:`CL` and :mod:`cl`,
 
1556
  :mod:`DEVICE`,
 
1557
  :mod:`ERRNO`,
 
1558
  :mod:`FILE`,
 
1559
  :mod:`FL` and :mod:`fl`,
 
1560
  :mod:`flp`,
 
1561
  :mod:`fm`,
 
1562
  :mod:`GET`,
 
1563
  :mod:`GLWS`,
 
1564
  :mod:`GL` and :mod:`gl`,
 
1565
  :mod:`IN`,
 
1566
  :mod:`IOCTL`,
 
1567
  :mod:`jpeg`,
 
1568
  :mod:`panelparser`,
 
1569
  :mod:`readcd`,
 
1570
  :mod:`SV` and :mod:`sv`,
 
1571
  :mod:`torgb`,
 
1572
  :mod:`videoreader`,
 
1573
  :mod:`WAIT`.
1449
1574
 
1450
1575
* The :mod:`bsddb.dbshelve` module now uses the highest pickling protocol
1451
1576
  available, instead of restricting itself to protocol 1.
1690
1815
 
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. ::
1694
1819
 
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.)
1730
1855
 
1731
 
* (3.0-warning mode) The :mod:`new` module has been removed from
1732
 
  Python 3.0.  Importing it therefore triggers a warning message.
1733
 
 
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`.)
1843
1965
 
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.
1947
2069
 
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 
2101
2223
 
2102
2224
  (Added by Facundo Batista.) 
2103
2225
 
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.)
 
2230
 
 
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
2141
2268
 
2142
2269
  (Contributed by Alan McIntyre; :issue:`467924`.)
2143
2270
 
 
2271
  Also, :mod:`zipfile` now supports using Unicode filenames
 
2272
  for archived files.  (Contributed by Alexey Borzenkov; :issue:`1734346`.)
 
2273
 
2144
2274
.. ======================================================================
2145
2275
.. whole new modules get described in subsections here
2146
2276
 
 
2277
The :mod:`json` module
 
2278
----------------------
 
2279
 
 
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.
 
2284
 
 
2285
:mod:`json` comes with support for decoding and encoding most builtin Python
 
2286
types. The following example encodes and decodes a dictionary::
 
2287
 
 
2288
       >>> import json
 
2289
       >>> data = {"spam" : "foo", "parrot" : 42}
 
2290
       >>> in_json = json.dumps(data) # Encode the data
 
2291
       >>> in_json
 
2292
       '{"parrot": 42, "spam": "foo"}'
 
2293
       >>> json.loads(in_json) # Decode into a Python object
 
2294
       {"spam" : "foo", "parrot" : 42}
 
2295
 
 
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.
 
2298
 
 
2299
:mod:`json` (originally called simplejson) was written by Bob Ippolito.
 
2300
 
 
2301
 
2147
2302
Improved SSL Support
2148
2303
--------------------------------------------------
2149
2304
 
2158
2313
 
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.
2162
 
 
2163
 
XXX Can specify if certificate is required, and obtain certificate info
2164
 
by calling getpeercert method.
2165
 
 
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.
2168
2318
 
2169
2319
.. seealso::
2170
2320
 
2171
 
   SSL module documentation.
 
2321
   The documentation for the :mod:`ssl` module.
2172
2322
 
2173
2323
 
2174
2324
.. ======================================================================
2322
2472
Port-Specific Changes: Windows
2323
2473
-----------------------------------
2324
2474
 
 
2475
* The support for Windows 95, 98, ME and NT4 has been dropped.
 
2476
  Python 2.6 requires at least Windows 2000 SP4.
 
2477
 
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