Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import types
- def check(object):
- print object,
- if type(object) is types.IntType:
- print "INTEGER",
- if type(object) is types.FloatType:
- print "FLOAT",
- if type(object) is types.StringType:
- print "STRING",
- if type(object) is types.ClassType:
- print "CLASS",
- if type(object) is types.InstanceType:
- print "INSTANCE",
- print
- check(0)
- check(0.0)
- check("0")
- class A:
- pass
- class B:
- pass
- check(A)
- check(B)
- a = A()
- b = B()
- check(a)
- check(b)
- ## 0 INTEGER
- ## 0.0 FLOAT
- ## 0 STRING
- ## A CLASS
- ## B CLASS
- ## <A instance at 796960> INSTANCE
- ## <B instance at 796990> INSTANCE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement