diff options
Diffstat (limited to 'Doc/whatsnew/3.0.rst')
-rw-r--r-- | Doc/whatsnew/3.0.rst | 45 |
1 files changed, 22 insertions, 23 deletions
diff --git a/Doc/whatsnew/3.0.rst b/Doc/whatsnew/3.0.rst index 549f314..852f811 100644 --- a/Doc/whatsnew/3.0.rst +++ b/Doc/whatsnew/3.0.rst @@ -96,9 +96,9 @@ up if you're used to Python 2.5. Print Is A Function ------------------- -The :keyword:`print` statement has been replaced with a :func:`print` +The ``print`` statement has been replaced with a :func:`print` function, with keyword arguments to replace most of the special syntax -of the old :keyword:`print` statement (:pep:`3105`). Examples:: +of the old ``print`` statement (:pep:`3105`). Examples:: Old: print "The answer is", 2*2 New: print("The answer is", 2*2) @@ -126,7 +126,7 @@ which produces:: Note: * The :func:`print` function doesn't support the "softspace" feature of - the old :keyword:`print` statement. For example, in Python 2.x, + the old ``print`` statement. For example, in Python 2.x, ``print "A\n", "B"`` would write ``"A\nB\n"``; but in Python 3.0, ``print("A\n", "B")`` writes ``"A\n B\n"``. @@ -135,7 +135,7 @@ Note: ``print(x)`` instead! * When using the ``2to3`` source-to-source conversion tool, all - :keyword:`print` statements are automatically converted to + ``print`` statements are automatically converted to :func:`print` function calls, so this is mostly a non-issue for larger projects. @@ -178,7 +178,7 @@ Python 3.0 has simplified the rules for ordering comparisons: meaningful natural ordering. Thus, expressions like ``1 < ''``, ``0 > None`` or ``len <= len`` are no longer valid, and e.g. ``None < None`` raises :exc:`TypeError` instead of returning - :keyword:`False`. A corollary is that sorting a heterogeneous list + ``False``. A corollary is that sorting a heterogeneous list no longer makes sense -- all the elements must be comparable to each other. Note that this does not apply to the ``==`` and ``!=`` operators: objects of different incomparable types always compare @@ -270,7 +270,7 @@ changed. single "euro" character. (Of course, this change only affects raw string literals; the euro character is ``'\u20ac'`` in Python 3.0.) -* The builtin :class:`basestring` abstract type was removed. Use +* The built-in :class:`basestring` abstract type was removed. Use :class:`str` instead. The :class:`str` and :class:`bytes` types don't have functionality enough in common to warrant a shared base class. The ``2to3`` tool (see below) replaces every occurrence of @@ -383,10 +383,10 @@ New Syntax literals (``0720``) are gone. * New binary literals, e.g. ``0b1010`` (already in 2.6), and - there is a new corresponding builtin function, :func:`bin`. + there is a new corresponding built-in function, :func:`bin`. * Bytes literals are introduced with a leading ``b`` or ``B``, and - there is a new corresponding builtin function, :func:`bytes`. + there is a new corresponding built-in function, :func:`bytes`. Changed Syntax -------------- @@ -397,9 +397,8 @@ Changed Syntax * :keyword:`as` and :keyword:`with` are now reserved words. (Since 2.6, actually.) -* :keyword:`True`, :keyword:`False`, and :keyword:`None` are reserved - words. (2.6 partially enforced the restrictions on :keyword:`None` - already.) +* ``True``, ``False``, and ``None`` are reserved words. (2.6 partially enforced + the restrictions on ``None`` already.) * Change from :keyword:`except` *exc*, *var* to :keyword:`except` *exc* :keyword:`as` *var*. See :pep:`3110`. @@ -506,7 +505,7 @@ consulted for longer descriptions. * :ref:`pep-3116`. The :mod:`io` module is now the standard way of doing file I/O, and the initial values of :data:`sys.stdin`, :data:`sys.stdout` and :data:`sys.stderr` are now instances of - :class:`io.TextIOBase`. The builtin :func:`open` function is now an + :class:`io.TextIOBase`. The built-in :func:`open` function is now an alias for :func:`io.open` and has additional keyword arguments *encoding*, *errors*, *newline* and *closefd*. Also note that an invalid *mode* argument now raises :exc:`ValueError`, not @@ -521,7 +520,7 @@ consulted for longer descriptions. * :ref:`pep-3119`. The :mod:`abc` module and the ABCs defined in the :mod:`collections` module plays a somewhat more prominent role in - the language now, and builtin collection types like :class:`dict` + the language now, and built-in collection types like :class:`dict` and :class:`list` conform to the :class:`collections.MutableMapping` and :class:`collections.MutableSequence` ABCs, respectively. @@ -615,7 +614,7 @@ review: Some other changes to standard library modules, not covered by :pep:`3108`: -* Killed :mod:`sets`. Use the builtin :func:`set` function. +* Killed :mod:`sets`. Use the built-in :func:`set` class. * Cleanup of the :mod:`sys` module: removed :func:`sys.exitfunc`, :func:`sys.exc_clear`, :data:`sys.exc_type`, :data:`sys.exc_value`, @@ -795,8 +794,8 @@ Builtins It raises :exc:`EOFError` if the input is terminated prematurely. To get the old behavior of :func:`input`, use ``eval(input())``. -* A new builtin :func:`next` was added to call the :meth:`__next__` - method on an object. +* A new built-in function :func:`next` was added to call the + :meth:`__next__` method on an object. * The :func:`round` function rounding strategy and return type have changed. Exact halfway cases are now rounded to the nearest even @@ -850,21 +849,21 @@ to the C API. * :pep:`3121`: Extension Module Initialization & Finalization. -* :pep:`3123`: Making :cmacro:`PyObject_HEAD` conform to standard C. +* :pep:`3123`: Making :c:macro:`PyObject_HEAD` conform to standard C. * No more C API support for restricted execution. -* :cfunc:`PyNumber_Coerce`, :cfunc:`PyNumber_CoerceEx`, - :cfunc:`PyMember_Get`, and :cfunc:`PyMember_Set` C APIs are removed. +* :c:func:`PyNumber_Coerce`, :c:func:`PyNumber_CoerceEx`, + :c:func:`PyMember_Get`, and :c:func:`PyMember_Set` C APIs are removed. -* New C API :cfunc:`PyImport_ImportModuleNoBlock`, works like - :cfunc:`PyImport_ImportModule` but won't block on the import lock +* New C API :c:func:`PyImport_ImportModuleNoBlock`, works like + :c:func:`PyImport_ImportModule` but won't block on the import lock (returning an error instead). * Renamed the boolean conversion C-level slot and method: ``nb_nonzero`` is now ``nb_bool``. -* Removed :cmacro:`METH_OLDARGS` and :cmacro:`WITH_CYCLE_GC` from the C API. +* Removed :c:macro:`METH_OLDARGS` and :c:macro:`WITH_CYCLE_GC` from the C API. .. ====================================================================== @@ -906,7 +905,7 @@ best strategy is the following: It is not recommended to try to write source code that runs unchanged under both Python 2.6 and 3.0; you'd have to use a very contorted -coding style, e.g. avoiding :keyword:`print` statements, metaclasses, +coding style, e.g. avoiding ``print`` statements, metaclasses, and much more. If you are maintaining a library that needs to support both Python 2.6 and Python 3.0, the best approach is to modify step 3 above by editing the 2.6 version of the source code and running the |