How to call a property of the base class if this property is being overwritten in the derived class?

前端 未结 7 731
無奈伤痛
無奈伤痛 2020-11-27 14:13

I\'m changing some classes of mine from an extensive use of getters and setters to a more pythonic use of properties.

But now I\'m stuck because some of my previous

7条回答
  •  一整个雨季
    2020-11-27 15:12

        class Base(object):
          def method(self):
            print "Base method was called"
    
        class Derived(Base):
          def method(self):
            super(Derived,self).method()
            print "Derived method was called"
    
        d = Derived()
        d.method()
    

    (that is unless I am missing something from your explanation)

提交回复
热议问题