0

As in this question, I am trying to call the method of a base class from a derived class:

class Base(object):
    def __get(self):
        print "Base::get"

class Derived(Base):
    def __init__(self):
        super(Derived,self).__get()

d=Derived()

Why does this code return AttributeError: 'super' object has no attribute '_Derived__get' ?

Community
  • 1
  • 1
Klaus
  • 1,241
  • 4
  • 14
  • 31
  • In super, put super(Base,self).__get() –  May 21 '16 at 15:25
  • 2
    @GabrielAlberto: nope, that is *very very wrong*, and has nothing to do with the error the OP sees. – Martijn Pieters May 21 '16 at 15:25
  • 1
    You can call `super(Derived, self)._Base__get()`, but that's best avoided. If you want a method to be 'visible' without the `_ClassName` prefix, then you should not use class-private naming (i.e. don't use two underscores for the name). – Martijn Pieters May 21 '16 at 15:37

0 Answers0