class A:
def __init__(self):
pass
class B(object):
def __init__(self):
pass
class C(A,B):
def __init__(self):
pass
class D(C):
def __init__(self):
pass
c1 = C()
d1 = D()
print "\n-------d1.__class__----------", d1.__class__
print "\n-------d1.__class__.__base__----------", d1.__class__.__base__
print "\n-------d1.__class__.__bases__----------", d1.__class__.__bases__
print "\n-------d1.__class__.__base__.__subclasses__()----------",
d1.__class__.__base__.__subclasses__()
print "\n-------d1.__class__.__mro__----------", d1.__class__.__mro__ #<-------
OUTPUT
=======
# python aa.py
-------d1.__class__---------- class '__main__.D'>
-------d1.__class__.__base__---------- class '__main__.C'>
-------d1.__class__.__bases__---------- (class '__main__.C'>,)
-------d1.__class__.__base__.__subclasses__()---------- [class '__main__.D'>]
-------d1.__class__.__mro__---------- (class '__main__.D'>, class '__main__.C'>,
class __main__.A at 0x7f4c135f0ad0>, class '__main__.B'>, type 'object'>)
Custom Search
Wednesday, December 15, 2010
python django how find class and base classes of an object
python django how find class and base classes of an object
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment