Add :term:s for "new-style class".

This commit is contained in:
Georg Brandl 2007-10-21 12:15:05 +00:00
parent e7a0990113
commit a739503881
11 changed files with 27 additions and 20 deletions

View file

@ -256,6 +256,8 @@ Glossary
access, adding thread-safety, tracking object creation, implementing
singletons, and many other tasks.
More information can be found in :ref:`metaclasses`.
mutable
Mutable objects can change their value but keep their :func:`id`. See
also :term:`immutable`.
@ -287,6 +289,8 @@ Glossary
descriptors, properties, :meth:`__getattribute__`, class methods, and
static methods.
More information can be found in :ref:`newstyle`.
Python 3000
Nickname for the next major Python version, 3.0 (coined long ago when the
release of version 3 was something in the distant future.)

View file

@ -1950,7 +1950,7 @@ Data types
in case the memory block contains pointers.
Common methods of ctypes data types, these are all class methods (to be exact,
they are methods of the metaclass):
they are methods of the :term:`metaclass`):
.. method:: _CData.from_address(address)

View file

@ -808,8 +808,8 @@ available. They are listed here in alphabetical order.
.. function:: property([fget[, fset[, fdel[, doc]]]])
Return a property attribute for new-style classes (classes that derive from
:class:`object`).
Return a property attribute for :term:`new-style class`\es (classes that
derive from :class:`object`).
*fget* is a function for getting an attribute value, likewise *fset* is a
function for setting, and *fdel* a function for del'ing, an attribute. Typical
@ -1112,8 +1112,8 @@ available. They are listed here in alphabetical order.
Return the superclass of *type*. If the second argument is omitted the super
object returned is unbound. If the second argument is an object,
``isinstance(obj, type)`` must be true. If the second argument is a type,
``issubclass(type2, type)`` must be true. :func:`super` only works for new-style
classes.
``issubclass(type2, type)`` must be true. :func:`super` only works for
:term:`new-style class`\es.
A typical use for calling a cooperative superclass method is::

View file

@ -122,7 +122,7 @@ There are currently 3 different protocols which can be used for pickling.
earlier versions of Python.
* Protocol version 2 was introduced in Python 2.3. It provides much more
efficient pickling of new-style classes.
efficient pickling of :term:`new-style class`\es.
Refer to :pep:`307` for more information.
@ -430,8 +430,8 @@ New-style types can provide a :meth:`__getnewargs__` method that is used for
protocol 2. Implementing this method is needed if the type establishes some
internal invariants when the instance is created, or if the memory allocation is
affected by the values passed to the :meth:`__new__` method for the type (as it
is for tuples and strings). Instances of a new-style type :class:`C` are
created using ::
is for tuples and strings). Instances of a :term:`new-style class` :class:`C`
are created using ::
obj = C.__new__(C, *args)
@ -459,8 +459,8 @@ can do what they want. [#]_
.. warning::
For new-style classes, if :meth:`__getstate__` returns a false value, the
:meth:`__setstate__` method will not be called.
For :term:`new-style class`\es, if :meth:`__getstate__` returns a false
value, the :meth:`__setstate__` method will not be called.
Pickling and unpickling extension types

View file

@ -549,7 +549,7 @@ string representation and register the function with :meth:`register_adapter`.
.. note::
The type/class to adapt must be a new-style class, i. e. it must have
The type/class to adapt must be a :term:`new-style class`, i. e. it must have
:class:`object` as one of its bases.
.. literalinclude:: ../includes/sqlite3/adapter_point_2.py

View file

@ -113,8 +113,9 @@ between conformable Python objects and XML on the wire.
The *use_datetime* flag was added.
.. versionchanged:: 2.6
Instances of new-style classes can be passed in if they have an *__dict__*
attribute and don't have a base class that is marshalled in a special way.
Instances of :term:`new-style class`\es can be passed in if they have an
*__dict__* attribute and don't have a base class that is marshalled in a
special way.
.. seealso::

View file

@ -534,8 +534,9 @@ must be given a value in the :meth:`__init__` method or in another method. Both
class and instance variables are accessible through the notation
"``self.name``", and an instance variable hides a class variable with the same
name when accessed in this way. Class variables with immutable values can be
used as defaults for instance variables. For new-style classes, descriptors can
be used to create instance variables with different implementation details.
used as defaults for instance variables. For :term:`new-style class`\es,
descriptors can be used to create instance variables with different
implementation details.
.. rubric:: Footnotes

View file

@ -1082,6 +1082,7 @@ Internal types
.. % Types
.. % =========================================================================
.. _newstyle:
New-style and classic classes
=============================

View file

@ -495,8 +495,8 @@ figure out the consequences of a name conflict with an attribute of
:class:`Base2`. The depth-first rule makes no differences between direct and
inherited attributes of :class:`Base1`.)
For new-style classes, the method resolution order changes dynamically to
support cooperative calls to :func:`super`. This approach is known in some
For :term:`new-style class`\es, the method resolution order changes dynamically
to support cooperative calls to :func:`super`. This approach is known in some
other multiple-inheritance languages as call-next-method and is more powerful
than the super call found in single-inheritance languages.