En Tue, 18 Sep 2007 04:33:11 -0300, exhuma.twn <[EMAIL PROTECTED]> escribi�:
> This is something that keeps confusing me. If you read examples of > code on the web, you keep on seeing these three calls (super, apply > and __init__) to reference the super-class. This looks to me as it is > somehow personal preference. But this would conflict with the "There > one way to do it" mind-set. > > So, knowing that in python there is one thing to do something, these > three different calls must *do* domething different. But what exactly > *is* the difference? There are a few typos in your examples. If you write them this way: > ------------ Exampel 1: ----------------------------- > > class B(A): > def __init__(self, *args): > A.__init__(self, *args) > > ------------ Exampel 2: ----------------------------- > > class B(A): > def __init__(self, *args): > apply( A.__init__, (self,) + args) > > ------------ Exampel 3: ----------------------------- > > class B(A): > def __init__(self, *args): > super(B,self).__init__(*args) then 2 is exactly the same as 1 but using a deprecated function. And 3 is the same as 1 only when there is single inheritance involved (and you are using new-style classes). But see the thread "super() doesn't get superclass" -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list