Home | Mirror | Search |
http://docs.python.org/library/types.html
>>> type( [] ) == list True >>> type( {} ) == dict True >>> type( "" ) == str True >>> type( 0 ) == int True >>> class Test1 ( object ): pass >>> class Test2 ( Test1 ): pass >>> a = Test1() >>> b = Test2() >>> type( a ) == Test1 True >>> type( b ) == Test2 True >>> type( b ) == Test1 False >>> isinstance( b, Test1 ) True >>> isinstance( b, Test2 ) True >>> isinstance( a, Test1 ) True >>> isinstance( a, Test2 ) False >>> isinstance( [], list ) True >>> isinstance( {}, dict ) True
>>> a = [] >>> type(a) <type 'list'> >>> f = () >>> type(f) <type 'tuple'>