Advertisement
Guest User

Untitled

a guest
May 22nd, 2015
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import types
  2.  
  3. def check(object):
  4. print object,
  5. if type(object) is types.IntType:
  6. print "INTEGER",
  7. if type(object) is types.FloatType:
  8. print "FLOAT",
  9. if type(object) is types.StringType:
  10. print "STRING",
  11. if type(object) is types.ClassType:
  12. print "CLASS",
  13. if type(object) is types.InstanceType:
  14. print "INSTANCE",
  15. print
  16.  
  17. check(0)
  18. check(0.0)
  19. check("0")
  20.  
  21. class A:
  22. pass
  23.  
  24. class B:
  25. pass
  26.  
  27. check(A)
  28. check(B)
  29.  
  30. a = A()
  31. b = B()
  32.  
  33. check(a)
  34. check(b)
  35.  
  36. ## 0 INTEGER
  37. ## 0.0 FLOAT
  38. ## 0 STRING
  39. ## A CLASS
  40. ## B CLASS
  41. ## <A instance at 796960> INSTANCE
  42. ## <B instance at 796990> INSTANCE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement