PyDocs

Nav

Python Runtime Services

type

  • type(object, /)
  • type(name, bases, dict, /, **kwargs)
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__.
Changed in 3.6, 3.15
  • 3.6: Subclasses of type which don’t override type.__new__ may no longer use the one-argument form to get the type of an object.
  • 3.15: dict can now be a frozendict.
Members of type

_

__annotate__
The annotate function for this class, or None if the class has no annotations.
__annotations__
A dictionary containing variable annotations collected during class body execution.
__base__
The base class of the class hierarchy.
__bases__
A tuple containing the class’s bases.
__dict__
A mapping proxy providing a read-only view of the class’s namespace.
__doc__
The class’s documentation string, or None if undefined.
__firstlineno__
The line number of the first line of the class definition, including decorators.
__instancecheck__
Check if an object is an instance.
__module__
The name of the module in which the class was defined.
__mro__
The tuple of classes that are considered when looking for base classes during method resolution.
__name__
The class’s name.
__qualname__
The class’s qualified name.
__static_attributes__
A tuple containing names of attributes of this class which are assigned through self.X from any function in its body.
__subclasscheck__
Check if a class is a subclass.
__subclasses__
Return a list of immediate subclasses.
__type_params__
A tuple containing the type parameters of a generic class.

m

mro
Return a type's method resolution order.
1 Example
>>> class X:
...     a = 1
...
>>> X = type('X', (), dict(a=1))
from the Python docs
See Also
No see-alsos for builtins/type
0 Notes
No notes for type