Skip to content

Instantly share code, notes, and snippets.

@berinhard
Last active December 19, 2015 02:59
Show Gist options
  • Save berinhard/5887347 to your computer and use it in GitHub Desktop.
Save berinhard/5887347 to your computer and use it in GitHub Desktop.
class Class1():
pass
class Class2():
pass
class Class3(object):
pass
a = Class1()
b = Class1()
assert True == isinstance(a, type(b))
assert True == isinstance(b, type(a))
c = Class2()
assert True == isinstance(c, type(a))
d = Class3()
assert False == isinstance(d, type(a))
assert False == isinstance(d, type(c))
assert False == isinstance(a, type(d))
assert False == isinstance(c, type(d))
print "tipo de a " + str(type(a))
print "tipo de d " + str(type(d))
#more info here: http://stackoverflow.com/questions/54867/old-style-and-new-style-classes-in-python
#and here: http://stackoverflow.com/questions/332255/difference-between-class-foo-and-class-fooobject-in-python
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment