diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2021-01-22 05:57:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 05:57:40 (GMT) |
commit | 34f3f4ac70e3ba2e603ba7792addf973c94f90cb (patch) | |
tree | 1091cccd137f0feeffbd9a697298f950ef85ba1a /Doc/library | |
parent | 844ec0ba6606b60a59b7da82c54c1e646424259c (diff) | |
download | cpython-34f3f4ac70e3ba2e603ba7792addf973c94f90cb.zip cpython-34f3f4ac70e3ba2e603ba7792addf973c94f90cb.tar.gz cpython-34f3f4ac70e3ba2e603ba7792addf973c94f90cb.tar.bz2 |
bpo-40304: Correct type(name, bases, dict) doc (GH-19553)
Co-authored-by: Éric Araujo <merwok@netwok.org>
Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu>
Co-authored-by: Tal Einat <532281+taleinat@users.noreply.github.com>
(cherry picked from commit 644d52818a6391535e5838fd57d58ffcb1163056)
Co-authored-by: Борис Верховский <boris.verk@gmail.com>
Diffstat (limited to 'Doc/library')
-rw-r--r-- | Doc/library/functions.rst | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Doc/library/functions.rst b/Doc/library/functions.rst index 4f5fe6b..5a039f7 100644 --- a/Doc/library/functions.rst +++ b/Doc/library/functions.rst @@ -1683,18 +1683,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)) See also :ref:`bltin-type-objects`. |