J
Jorgen Bodde
Hi All,
Now that I am really diving into Python, I encounter a lot of things
that us newbies find difficult to get right. I thought I understood
how super() worked, but with 'private' members it does not seem to
work. For example;
.... def __baseMethod(self):
.... print 'Test'
Deriving from A, and doing;
.... def someMethod(self):
.... super(A, self).__baseMethod()
.... print 'test3'
Will not work;
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "<interactive input>", line 3, in someMethod
AttributeError: 'super' object has no attribute '_D__baseMethod'
Is it possible to call a private base method? I come from a C++
background, and I liked this construction as my base class has helper
methods so that I do not have to duplicate code.
When I do;
.... def someMethod(self):
.... print 'Hello'
........ def otherMethod(self):
.... super(F, self).someMethod()
.... print 'There'
....
This seems to work.
Thanks in advance,
- Jorgen
Now that I am really diving into Python, I encounter a lot of things
that us newbies find difficult to get right. I thought I understood
how super() worked, but with 'private' members it does not seem to
work. For example;
.... def __baseMethod(self):
.... print 'Test'
Deriving from A, and doing;
.... def someMethod(self):
.... super(A, self).__baseMethod()
.... print 'test3'
Will not work;
Traceback (most recent call last):
File "<interactive input>", line 1, in <module>
File "<interactive input>", line 3, in someMethod
AttributeError: 'super' object has no attribute '_D__baseMethod'
Is it possible to call a private base method? I come from a C++
background, and I liked this construction as my base class has helper
methods so that I do not have to duplicate code.
When I do;
.... def someMethod(self):
.... print 'Hello'
........ def otherMethod(self):
.... super(F, self).someMethod()
.... print 'There'
....
Hello
There
This seems to work.
Thanks in advance,
- Jorgen