The following example shows how to discover and experiment with built-in types.
Example 3.1. More built-in types
>>> import types>>> types.ListType is list
True >>> def f():
... pass ... >>> f.__class__ is types.FunctionType
True >>> >>> class MyList(list):
... pass ... >>> class MyFunction(types.FunctionType):
... pass ... Traceback (most recent call last): File "<stdin>", line 1, in ? TypeError: type 'function' is not an acceptable base type >>> dir(types)
['BooleanType', 'DictProxyType', 'DictType', ..]
>>> types.ListType is list
True
>>> def f():
... pass
...
>>> f.__class__ is types.FunctionType
True
>>>
>>> class MyList(list):
... pass
...
>>> class MyFunction(types.FunctionType):
... pass
...
Traceback (most recent call last):
File "<stdin>", line 1, in ?
TypeError: type 'function' is not an acceptable base type
>>> dir(types)
['BooleanType', 'DictProxyType', 'DictType', ..]