mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
#16210: merge with 3.3.
This commit is contained in:
commit
93653c48e6
2 changed files with 12 additions and 15 deletions
|
@ -1323,29 +1323,25 @@ are always available. They are listed here in alphabetical order.
|
||||||
|
|
||||||
|
|
||||||
.. function:: type(object)
|
.. function:: type(object)
|
||||||
|
type(name, bases, dict)
|
||||||
|
|
||||||
.. index:: object: type
|
.. index:: object: type
|
||||||
|
|
||||||
Return the type of an *object*. The return value is a type object and
|
|
||||||
generally the same object as returned by ``object.__class__``.
|
With one argument, return the type of an *object*. The return value is a
|
||||||
|
type object and generally the same object as returned by ``object.__class__``.
|
||||||
|
|
||||||
The :func:`isinstance` built-in function is recommended for testing the type
|
The :func:`isinstance` built-in function is recommended for testing the type
|
||||||
of an object, because it takes subclasses into account.
|
of an object, because it takes subclasses into account.
|
||||||
|
|
||||||
With three arguments, :func:`type` functions as a constructor as detailed
|
|
||||||
below.
|
|
||||||
|
|
||||||
|
With three arguments, return a new type object. This is essentially a
|
||||||
.. function:: type(name, bases, dict)
|
dynamic form of the :keyword:`class` statement. The *name* string is the
|
||||||
:noindex:
|
class name and becomes the :attr:`__name__` attribute; the *bases* tuple
|
||||||
|
itemizes the base classes and becomes the :attr:`__bases__` attribute;
|
||||||
Return a new type object. This is essentially a dynamic form of the
|
and the *dict* dictionary is the namespace containing definitions for class
|
||||||
:keyword:`class` statement. The *name* string is the class name and becomes the
|
body and becomes the :attr:`__dict__` attribute. For example, the
|
||||||
:attr:`__name__` attribute; the *bases* tuple itemizes the base classes and
|
following two statements create identical :class:`type` objects:
|
||||||
becomes the :attr:`__bases__` attribute; and the *dict* dictionary is the
|
|
||||||
namespace containing definitions for class body and becomes the :attr:`__dict__`
|
|
||||||
attribute. For example, the following two statements create identical
|
|
||||||
:class:`type` objects:
|
|
||||||
|
|
||||||
>>> class X:
|
>>> class X:
|
||||||
... a = 1
|
... a = 1
|
||||||
|
|
|
@ -1060,6 +1060,7 @@ Iñigo Serna
|
||||||
Joakim Sernbrant
|
Joakim Sernbrant
|
||||||
Roger D. Serwy
|
Roger D. Serwy
|
||||||
Jerry Seutter
|
Jerry Seutter
|
||||||
|
Pete Sevander
|
||||||
Denis Severson
|
Denis Severson
|
||||||
Ian Seyer
|
Ian Seyer
|
||||||
Ha Shao
|
Ha Shao
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue