FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

bpo-40304: Correct type(name, bases, dict) doc by verhovsky · Pull Request #19553 · python/cpython · GitHub

Repository navigation

17 changes: 9 additions & 8 deletions Doc/library/functions.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1703,18 +1703,19 @@ are always available. They are listed here in alphabetical order.


With three arguments, return a new type object. This is essentially a
dynamic form of the :keyword:`class` statement. The *name* string is the
class name and becomes the :attr:`~definition.__name__` attribute; the *bases*
tuple itemizes the base classes and becomes the :attr:`~class.__bases__`
attribute; and the *dict* dictionary is the namespace containing definitions
for class body and is copied to a standard dictionary to become the
:attr:`~object.__dict__` attribute. For example, the following two
statements create identical :class:`type` objects:
dynamic form of the :keyword:`class` statement. The *name* string is
the class name and becomes the :attr:`~definition.__name__` attribute.
The *bases* tuple contains the base classes and becomes the
:attr:`~class.__bases__` attribute; if empty, :class:`object`, the
ultimate base of all classes, is added. The *dict* dictionary contains
attribute and method definitions for the class body; it may be copied
or wrapped before becoming the :attr:`~object.__dict__` attribute.
The following two statements create identical :class:`type` objects:

>>> class X:
... a = 1
...
>>> X = type('X', (object,), dict(a=1))
>>> X = type('X', (), dict(a=1))
Comment thread
terryjreedy marked this conversation as resolved.
Resolved

See also :ref:`bltin-type-objects`.

Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix doc for type(name, bases, dict). Patch by Boris Verkhovskiy and
Éric Araujo.

Back | FazBrowse Home | New Git URL