mirror of
https://github.com/python/cpython.git
synced 2024-11-25 02:44:06 +08:00
Remove versionadded/versionchanged in the reference.
This commit is contained in:
parent
321976b6e7
commit
1617457cff
@ -211,6 +211,7 @@ The :keyword:`try` statement
|
||||
============================
|
||||
|
||||
.. index:: statement: try
|
||||
.. index:: keyword: except
|
||||
|
||||
The :keyword:`try` statement specifies exception handlers and/or cleanup code
|
||||
for a group of statements:
|
||||
@ -224,13 +225,6 @@ for a group of statements:
|
||||
try2_stmt: "try" ":" `suite`
|
||||
: "finally" ":" `suite`
|
||||
|
||||
.. versionchanged:: 2.5
|
||||
In previous versions of Python, :keyword:`try`...\ :keyword:`except`...\
|
||||
:keyword:`finally` did not work. :keyword:`try`...\ :keyword:`except` had to be
|
||||
nested in :keyword:`try`...\ :keyword:`finally`.
|
||||
|
||||
.. index:: keyword: except
|
||||
|
||||
The :keyword:`except` clause(s) specify one or more exception handlers. When no
|
||||
exception occurs in the :keyword:`try` clause, no exception handler is executed.
|
||||
When an exception occurs in the :keyword:`try` suite, a search for an exception
|
||||
@ -317,8 +311,6 @@ The :keyword:`with` statement
|
||||
|
||||
.. index:: statement: with
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
The :keyword:`with` statement is used to wrap the execution of a block with
|
||||
methods defined by a context manager (see section :ref:`context-managers`). This
|
||||
allows common :keyword:`try`...\ :keyword:`except`...\ :keyword:`finally` usage
|
||||
|
@ -508,9 +508,6 @@ Callable types
|
||||
|
||||
Most of the attributes labelled "Writable" check the type of the assigned value.
|
||||
|
||||
.. versionchanged:: 2.4
|
||||
``__name__`` is now writable.
|
||||
|
||||
Function objects also support getting and setting arbitrary attributes, which
|
||||
can be used, for example, to attach metadata to functions. Regular attribute
|
||||
dot-notation is used to get and set such attributes. *Note that the current
|
||||
@ -550,9 +547,6 @@ Callable types
|
||||
``im_func.__name__``); :attr:`__module__` is the name of the module the method
|
||||
was defined in, or ``None`` if unavailable.
|
||||
|
||||
.. versionchanged:: 2.2
|
||||
:attr:`im_self` used to refer to the class that defined the method.
|
||||
|
||||
.. index::
|
||||
single: __doc__ (method attribute)
|
||||
single: __name__ (method attribute)
|
||||
@ -1029,8 +1023,6 @@ Internal types
|
||||
slice. Missing or out-of-bounds indices are handled in a manner consistent with
|
||||
regular slices.
|
||||
|
||||
.. versionadded:: 2.3
|
||||
|
||||
Static method objects
|
||||
Static method objects provide a way of defeating the transformation of function
|
||||
objects to method objects described above. A static method object is a wrapper
|
||||
@ -1240,8 +1232,6 @@ Basic customization
|
||||
object.__gt__(self, other)
|
||||
object.__ge__(self, other)
|
||||
|
||||
.. versionadded:: 2.1
|
||||
|
||||
These are the so-called "rich comparison" methods, and are called for comparison
|
||||
operators in preference to :meth:`__cmp__` below. The correspondence between
|
||||
operator symbols and method names is as follows: ``x<y`` calls ``x.__lt__(y)``,
|
||||
@ -1286,17 +1276,12 @@ Basic customization
|
||||
not propagated by :meth:`__cmp__` has been removed since Python 1.5.)
|
||||
|
||||
|
||||
.. method:: object.__rcmp__(self, other)
|
||||
|
||||
.. versionchanged:: 2.1
|
||||
No longer supported.
|
||||
|
||||
|
||||
.. method:: object.__hash__(self)
|
||||
|
||||
.. index::
|
||||
object: dictionary
|
||||
builtin: hash
|
||||
single: __cmp__() (object method)
|
||||
|
||||
Called for the key object for dictionary operations, and by the built-in
|
||||
function :func:`hash`. Should return a 32-bit integer usable as a hash value
|
||||
@ -1312,11 +1297,8 @@ Basic customization
|
||||
key's hash value is immutable (if the object's hash value changes, it will be in
|
||||
the wrong hash bucket).
|
||||
|
||||
.. versionchanged:: 2.5
|
||||
:meth:`__hash__` may now also return a long integer object; the 32-bit integer
|
||||
is then derived from the hash of that object.
|
||||
|
||||
.. index:: single: __cmp__() (object method)
|
||||
:meth:`__hash__` may also return a long integer object; the 32-bit integer is
|
||||
then derived from the hash of that object.
|
||||
|
||||
|
||||
.. method:: object.__bool__(self)
|
||||
@ -1502,9 +1484,9 @@ saved because *__dict__* is not created for each instance.
|
||||
class, *__slots__* reserves space for the declared variables and prevents the
|
||||
automatic creation of *__dict__* and *__weakref__* for each instance.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
Notes on using *__slots__*
|
||||
""""""""""""""""""""""""""
|
||||
|
||||
* Without a *__dict__* variable, instances cannot be assigned new variables not
|
||||
listed in the *__slots__* definition. Attempts to assign to an unlisted
|
||||
@ -1512,20 +1494,11 @@ Notes on using *__slots__*
|
||||
variables is desired, then add ``'__dict__'`` to the sequence of strings in
|
||||
the *__slots__* declaration.
|
||||
|
||||
.. versionchanged:: 2.3
|
||||
Previously, adding ``'__dict__'`` to the *__slots__* declaration would not
|
||||
enable the assignment of new attributes not specifically listed in the sequence
|
||||
of instance variable names.
|
||||
|
||||
* Without a *__weakref__* variable for each instance, classes defining
|
||||
*__slots__* do not support weak references to its instances. If weak reference
|
||||
support is needed, then add ``'__weakref__'`` to the sequence of strings in the
|
||||
*__slots__* declaration.
|
||||
|
||||
.. versionchanged:: 2.3
|
||||
Previously, adding ``'__weakref__'`` to the *__slots__* declaration would not
|
||||
enable support for weak references.
|
||||
|
||||
* *__slots__* are implemented at the class level by creating descriptors
|
||||
(:ref:`descriptors`) for each variable name. As a result, class attributes
|
||||
cannot be used to set default values for instance variables defined by
|
||||
@ -1550,10 +1523,6 @@ Notes on using *__slots__*
|
||||
|
||||
* *__class__* assignment works only if both classes have the same *__slots__*.
|
||||
|
||||
.. versionchanged:: 2.6
|
||||
Previously, *__class__* assignment raised an error if either new or old class
|
||||
had *__slots__*.
|
||||
|
||||
|
||||
.. _metaclasses:
|
||||
|
||||
@ -1581,8 +1550,6 @@ process:
|
||||
and ``dict``. Upon class creation, the callable is used instead of the built-in
|
||||
:func:`type`.
|
||||
|
||||
.. versionadded:: 2.2
|
||||
|
||||
The appropriate metaclass is determined by the following precedence rules:
|
||||
|
||||
* If ``dict['__metaclass__']`` exists, it is used.
|
||||
@ -1967,16 +1934,12 @@ left undefined.
|
||||
an integer object (such as in slicing, or in the built-in :func:`bin`,
|
||||
:func:`hex` and :func:`oct` functions). Must return an integer (int or long).
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
|
||||
.. _context-managers:
|
||||
|
||||
With Statement Context Managers
|
||||
-------------------------------
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
A :dfn:`context manager` is an object that defines the runtime context to be
|
||||
established when executing a :keyword:`with` statement. The context manager
|
||||
handles the entry into, and the exit from, the desired runtime context for the
|
||||
|
@ -294,8 +294,6 @@ Yield expressions
|
||||
yield_atom: "(" `yield_expression` ")"
|
||||
yield_expression: "yield" [`expression_list`]
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
The :keyword:`yield` expression is only used when defining a generator function,
|
||||
and can only be used in the body of a function definition. Using a
|
||||
:keyword:`yield` expression in a function definition is sufficient to cause that
|
||||
@ -1024,9 +1022,6 @@ substring of *y*. An equivalent test is ``y.find(x) != -1``. Empty strings are
|
||||
always considered to be a substring of any other string, so ``"" in "abc"`` will
|
||||
return ``True``.
|
||||
|
||||
.. versionchanged:: 2.3
|
||||
Previously, *x* was required to be a string of length ``1``.
|
||||
|
||||
For user-defined classes which define the :meth:`__contains__` method, ``x in
|
||||
y`` is true if and only if ``y.__contains__(x)`` is true.
|
||||
|
||||
@ -1089,8 +1084,6 @@ The expression ``x if C else y`` first evaluates *C* (*not* *x*); if *C* is
|
||||
true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated
|
||||
and its value is returned.
|
||||
|
||||
.. versionadded:: 2.5
|
||||
|
||||
.. index:: operator: and
|
||||
|
||||
The expression ``x and y`` first evaluates *x*; if *x* is false, its value is
|
||||
|
Loading…
Reference in New Issue
Block a user