Use __class__, __bases__ and __dict__ for sub and super class
class super:
def hello(self):
self.data1 = 'spam'
class sub(super):
def hola(self):
self.data2 = 'eggs'
X = sub()
X.__dict__
{}
print X.__class__
print sub.__bases__
print super.__bases__
Y = sub()
X.hello()
print X.__dict__
X.hola()
print X.__dict__
print sub.__dict__
print super.__dict__
print sub.__dict__.keys(), super.__dict__.keys()
print Y.__dict__
print X.data1, X.__dict__['data1']
X.data3 = 'toast'
print X.__dict__
X.__dict__['data3'] = 'ham'
print X.data3
print X.__dict__
print X.__dict__.keys()
print dir(X)
print dir(sub)
print dir(super)
Related examples in the same category