Код: Выделить всё
#!/usr/bin/python
class SuperHero(object):
def setName(self, name):
self.name = name
def getName(self):
return self.name
class SuperMan(SuperHero):
pass
if __name__ == "__main__":
sh = SuperHero()
sh.setName("Clark Kent")
sm = SuperMan(sh) # This does *not* work in real python
print sm.getName() # prints "Clark Kent"
Подробнее здесь: https://stackoverflow.com/questions/216 ... erived-one
Мобильная версия