types模块成员: 定义所有类型符号的名字,在标准的解释器中所知。
['BooleanType', 'BufferType', 'BuiltinFunctionType', 'BuiltinMethodType', 'ClassType', 'CodeType', 'ComplexType', 'DictProxyType', 'DictType', 'DictionaryType', 'EllipsisType', 'FileType', 'FloatType', 'FrameType', 'FunctionType', 'GeneratorType', 'GetSetDescriptorType', 'InstanceType', 'IntType', 'LambdaType', 'ListType', 'LongType', 'MemberDescriptorType', 'MethodType', 'ModuleType', 'NoneType', 'NotImplementedType', 'ObjectType', 'SliceType', 'StringType', 'StringTypes', 'TracebackType', 'TupleType', 'TypeType', 'UnboundMethodType', 'UnicodeType', 'XRangeType', '__builtins__', '__doc__', '__file__', '__name__', '__package__']
内置函数( built-in function ):
isinstance, len, repr,,
内置类型 ( type ):
bool, buffer, complex, dict, ellipsis, float, int,list, long,NoneType, object, slice, str, tuple, type, xrange, unicode
isinstance
isinstance(...)
isinstance(object, class-or-type-or-tuple) -> boolReturn whether anobject is an instance of a classor of a subclass thereof.
With a typeas second argument, return whether that is the object's type.
The form using a tuple, isinstance(x, (A, B, ...)), is a shortcut forisinstance(x, A) or isinstance(x, B) or ... (etc.).
repr
repr(...)
repr(object) -> stringReturn the canonical string representation of the object.
For most object types, eval(repr(object)) == object.
type
class type(object)| type(object) -> the object's type
| type(name, bases, dict) -> a newtype|
|Methods defined here:|
|__call__(...)| x.__call__(...) <==>x(...)|
|__delattr__(...)| x.__delattr__('name') <==>del x.name|
|__eq__(...)| x.__eq__(y) <==> x==y|
|__ge__(...)| x.__ge__(y) <==> x>=y|
|__getattribute__(...)| x.__getattribute__('name') <==>x.name|
|__gt__(...)| x.__gt__(y) <==> x>y|
|__hash__(...)| x.__hash__() <==>hash(x)|
|__init__(...)| x.__init__(...) initializes x; see help(type(x)) forsignature|
|__instancecheck__(...)| __instancecheck__() -> bool
| check if an object isan instance|
|__le__(...)| x.__le__(y) <==> x<=y|
|__lt__(...)| x.__lt__(y) <==> x
|__ne__(...)| x.__ne__(y) <==> x!=y|
|__repr__(...)| x.__repr__() <==>repr(x)|
|__setattr__(...)| x.__setattr__('name', value) <==> x.name =value|
|__subclasscheck__(...)| __subclasscheck__() -> bool
| check if a class isa subclass|
|__subclasses__(...)| __subclasses__() ->list of immediate subclasses|
|mro(...)| mro() ->list| return a type's method resolution order
|
| ----------------------------------------------------------------------
|Data descriptors defined here:|
|__abstractmethods__|
|__base__|
|__bases__|
|__basicsize__|
|__dict__|
|__dictoffset__|
|__flags__|
|__itemsize__|
|__mro__|
|__weakrefoffset__|
| ----------------------------------------------------------------------
|Data and other attributes defined here:|
| __new__ =
| T.__new__(S, ...) -> a new object with type S, a subtype of T