We're back after a server migration that caused effbot.org to fall over a bit harder than expected. Expect some glitches.



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.