Some textual tweaks, and fixed a few typos found by a spell checker.

This commit is contained in:
Guido van Rossum 2008-12-03 05:39:28 +00:00
parent b768d4f759
commit 08388ef361
1 changed files with 39 additions and 26 deletions

View File

@ -55,17 +55,26 @@
This article explains the new features in Python 3.0, compared to 2.6. This article explains the new features in Python 3.0, compared to 2.6.
Python 3.0, also known as "Python 3000" or "Py3K", is the first ever Python 3.0, also known as "Python 3000" or "Py3K", is the first ever
*intentionally incompatible* release. There are more changes than in *intentionally backwards incompatible* Python release. There are more
a typical release, and more that are important for all Python users. changes than in a typical release, and more that are important for all
Nevertheless, after digesting the changes, you'll find that Python Python users. Nevertheless, after digesting the changes, you'll find
really hasn't changed all that much -- by and large, we're merely that Python really hasn't changed all that much -- by and large, we're
fixing well-known annoyances and warts. mostly fixing well-known annoyances and warts, and removing a lot of
old cruft.
This article doesn't attempt to provide a complete specification of This article doesn't attempt to provide a complete specification of
the new features, but instead provides a convenient overview. For all new features, but instead tries to give a convenient overview.
full details, you should refer to the documentation for Python 3.0. If For full details, you should refer to the documentation for Python
you want to understand the complete implementation and design 3.0, and/or the many PEPs referenced in the text. If you want to
rationale, refer to the PEP for a particular new feature. understand the complete implementation and design rationale for a
particular feature, PEPs usually have more details than the regular
documentation; but note that PEPs usually are not kept up-to-date once
a feature has been fully implemented.
Due to time constraints this document is not as complete as it should
have been. As always for a new release, the ``Misc/NEWS`` file in the
source distribution contains a wealth of detailed information about
every small thing that was changed.
.. Compare with previous release in 2 - 3 sentences here. .. Compare with previous release in 2 - 3 sentences here.
.. add hyperlink when the documentation becomes available online. .. add hyperlink when the documentation becomes available online.
@ -144,11 +153,14 @@ Some well-known APIs no longer return lists:
* Also, the :meth:`dict.iterkeys`, :meth:`dict.iteritems` and * Also, the :meth:`dict.iterkeys`, :meth:`dict.iteritems` and
:meth:`dict.itervalues` methods are no longer supported. :meth:`dict.itervalues` methods are no longer supported.
* :func:`map` and :func:`filter` return iterators. A quick fix is e.g. * :func:`map` and :func:`filter` return iterators. If you really need
``list(map(...))``, but a better fix is often to use a list a list, a quick fix is e.g. ``list(map(...))``, but a better fix is
comprehension (especially when the original code uses :keyword:`lambda`). often to use a list comprehension (especially when the original code
Particularly tricky is :func:`map` invoked for the side effects of the uses :keyword:`lambda`), or rewriting the code so it doesn't need a
function; the correct transformation is to use a for-loop. list at all. Particularly tricky is :func:`map` invoked for the
side effects of the function; the correct transformation is to use a
regular :keyword:`for` loop (since creating a list would just be
wasteful).
* :func:`range` now behaves like :func:`xrange` used to behave, except * :func:`range` now behaves like :func:`xrange` used to behave, except
it works with values of arbitrary size. The latter no longer it works with values of arbitrary size. The latter no longer
@ -164,13 +176,14 @@ Python 3.0 has simplified the rules for ordering comparisons:
* The ordering comparison operators (``<``, ``<=``, ``>=``, ``>``) * The ordering comparison operators (``<``, ``<=``, ``>=``, ``>``)
raise a TypeError exception when the operands don't have a raise a TypeError exception when the operands don't have a
meaningful natural ordering. Thus, expressions like ``1 < ''``, ``0 meaningful natural ordering. Thus, expressions like ``1 < ''``, ``0
> None`` or ``len <= len`` are no longer valid. A corollary is that > None`` or ``len <= len`` are no longer valid, and e.g. ``None <
sorting a heterogeneous list no longer makes sense -- all the None`` raises :exc:`TypeError` instead of returning
elements must be comparable to each other. Note that this does not :keyword:`False`. A corollary is that sorting a heterogeneous list
apply to the ``==`` and ``!=`` operators: objects of different no longer makes sense -- all the elements must be comparable to each
uncomparable types always compare unequal to each other, and an other. Note that this does not apply to the ``==`` and ``!=``
object always compares equal to itself (i.e., ``x is y`` implies operators: objects of different incomparable types always compare
``x == y``; this is true even for *NaN*). unequal to each other, and an object always compares equal to itself
(i.e., ``x is y`` implies ``x == y``; this is true even for *NaN*).
* :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the * :meth:`builtin.sorted` and :meth:`list.sort` no longer accept the
*cmp* argument providing a comparison function. Use the *key* *cmp* argument providing a comparison function. Use the *key*
@ -196,7 +209,7 @@ Integers
existed for years, at least since Python 2.2.) existed for years, at least since Python 2.2.)
* The :data:`sys.maxint` constant was removed, since there is no * The :data:`sys.maxint` constant was removed, since there is no
longer a limit to the value of ints. However, :data:`sys.maxsize` longer a limit to the value of integers. However, :data:`sys.maxsize`
can be used as an integer larger than any practical list or string can be used as an integer larger than any practical list or string
index. It conforms to the implementation's "natural" integer size index. It conforms to the implementation's "natural" integer size
and is typically the same as :data:`sys.maxint` in previous releases and is typically the same as :data:`sys.maxint` in previous releases
@ -542,7 +555,7 @@ review:
* The :mod:`bsddb3` package was removed because its presence in the * The :mod:`bsddb3` package was removed because its presence in the
core standard library has proved over time to be a particular burden core standard library has proved over time to be a particular burden
for the core developers due to testing instability and Berlekey DB's for the core developers due to testing instability and Berkeley DB's
release schedule. However, the package is alive and well, release schedule. However, the package is alive and well,
externally maintained at http://www.jcea.es/programacion/pybsddb.htm. externally maintained at http://www.jcea.es/programacion/pybsddb.htm.
@ -599,8 +612,8 @@ review:
* :mod:`xmlrpc` (:mod:`xmlrpclib`, :mod:`DocXMLRPCServer`, * :mod:`xmlrpc` (:mod:`xmlrpclib`, :mod:`DocXMLRPCServer`,
:mod:`SimpleXMLRPCServer`). :mod:`SimpleXMLRPCServer`).
modules
Some other changes to standard library moduled, not covered by Some other changes to standard library modules, not covered by
:pep:`3108`: :pep:`3108`:
* Killed :mod:`sets`. Use the builtin :func:`set` function. * Killed :mod:`sets`. Use the builtin :func:`set` function.
@ -840,7 +853,7 @@ to the C API.
* Renamed the boolean conversion C-level slot and method: * Renamed the boolean conversion C-level slot and method:
``nb_nonzero`` is now ``nb_bool``. ``nb_nonzero`` is now ``nb_bool``.
* Removed ``METH_OLDARGS`` and ``WITH_CYCLE_GC`` from the C API. * Removed :cmacro:`METH_OLDARGS` and :cmacro:`WITH_CYCLE_GC` from the C API.
.. ====================================================================== .. ======================================================================