Created
January 8, 2012 20:38
-
-
Save ksato9700/1579602 to your computer and use it in GitHub Desktop.
How to check python class instance
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<type 'instance'> __main__.A True True | |
<class '__main__.B'> <class '__main__.B'> True True | |
<type 'int'> <type 'int'> False False | |
<type 'tuple'> <type 'tuple'> False False | |
<type 'list'> <type 'list'> False False | |
<type 'dict'> <type 'dict'> False False | |
<class '__main__.DD'> <class '__main__.DD'> True True | |
<type 'bool'> <type 'bool'> False False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class A: pass | |
class B(object): pass | |
class DD(dict): pass | |
a = A() | |
b = B() | |
i = 0 | |
t = () | |
l = [] | |
d = {} | |
dd = DD() | |
f = False | |
for p in (a, b, i, t, l, d, dd, f): | |
print type(p), | |
print p.__class__, | |
print hasattr(p, "__dict__"), | |
print p.__class__.__module__ != "__builtin__" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment