Carl Karsten wrote:
> johnf wrote:
>> Hi,
>> I think I'll start adding small stuff first
>> Please review and add to the question wiki.
>>
>>
>> What, why and how of "doDefault()"
>>
>> What is “doDefault()”?
>> Executes the parent class event or method of the same name from within a
>> subclass.
>
> does python use the term "event" ? if not, best not to introduce it.
Correct: we are only talking methods here, not events.
> is doDefault() a dabo thing? I was under the impression it was python, but I
> am
doDefault() is Dabo. self.super() is Dabo. What Python has is super():
class A(object):
def myMethod(self):
print "in A"
class B(A):
def myMethod(self):
print "In B"
super(B, self).myMethod()
B().myMethod()
In B
In A
Notice how you need to explicity type the subclass ref, self, and the
method name you want to call. This is what Dabo's self.super() does for you:
import dabo
class A(dabo.dObject):
def myMethod(self):
print "in A"
class B(A):
def myMethod(self):
print "In B"
self.super()
B().myMethod()
In B
In A
> not finding that. I do see Super.foo() to call the parent classes foo(),
> wich
> will climb up till it finds foo defined. Is that the python way?
The python way is super(cls, self).foo().
--
pkm ~ http://paulmcnett.com
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev