Sheep

The following list shows a few of the more common types you'll use.

BuiltinFunctionType

FunctionType

MethodType

BuiltinMethodType

InstanceType

ModuleType

ClassType

IntType

NoneType

DictType

LambdaType

StringType

FileType

ListType

TupleType

FloatType

LongType

Classes and instances of classes have the types ClassType and InstanceType, respectively. Python provides the isinstance(obj) and issubclass(obj) functions to test if an object is an instance or a subclass of a particular type:

>>> isinstance(5.1,types.FloatType) 1

>>> a = Foo() >>> isinstance(a,Foo) 1

Chapter 7 covers creating and using classes and objects.

0 0

Post a comment