def fn(self,name = "world"): print "hello,%s"%name
class Animal(object): @property def ani(self): print "Animal" class Fly(Animal): @property def fly(self): print "Fly" class Dog(Animal): @property def dog(self): print "Dog" class Bat(Fly): pass
#这个class 名称是不是必须跟类名一样?
#我测试过!不一定,但是最好写一样吧! Test = type("Test",(Fly,Animal),dict(hello = fn))
#继承多重父类,可调用继承的属性! h = Test() h.hello() h.ani h.fly
#h.dog() 非继承不可调用!
Sign in to make a reply
神月宗
def fn(self,name = "world"): print "hello,%s"%name
class Animal(object): @property def ani(self): print "Animal" class Fly(Animal): @property def fly(self): print "Fly" class Dog(Animal): @property def dog(self): print "Dog" class Bat(Fly): pass
#这个class 名称是不是必须跟类名一样?
#我测试过!不一定,但是最好写一样吧! Test = type("Test",(Fly,Animal),dict(hello = fn))
#继承多重父类,可调用继承的属性! h = Test() h.hello() h.ani h.fly
#h.dog() 非继承不可调用!