type
type(object)
Returns the type of an object. The return value is a type object. The isinstance built-in function is recommended for testing the type of an object.
When used with three arguments, type functions as a constructor as detailed below.
type(name, bases, dict)
Return a new type object. This is essentially a dynamic form of the class statement. The name string is the class name and becomes the __name__ attribute; the bases tuple itemizes the base classes and becomes the __bases__ attribute; and the dict dictionary is the namespace containing definitions for class body and becomes the __dict__ attribute. For example, the following two statements create identical type objects:
>>> class X(object):
... a = 1
...
>>> X = type('X', (object,), dict(a=1))
New in version 2.2.
last updated 2 years ago by effbot #
