[Tutor] Objects & Classes...

jfouhy at paradise.net.nz jfouhy at paradise.net.nz
Mon Jan 17 22:02:49 CET 2005


On Mon, 2005-01-17 at 10:59 -0800, Chad Crabtree wrote:
> class NewCharacter(Character):
>   def __init__(self,stats,*args,**kwds):
>     super(Character,self).__init__(*args,**kwds)
>     self.stats=stats
> 
> super is a function that calls a specific function from a parent
> class. This way you can still use the previous __init__ code and then extend
> it. 

Is that the right idiom these days?

I would write:

def __init__(self, stats, *args, **kw):
    Character.__init__(self, *args, **kw)
    self.stats = stats

-- 
John.


More information about the Tutor mailing list