[Tutor] Calling super classs __init__?

Allen Fowler allen.fowler at yahoo.com
Wed Mar 19 05:01:25 CET 2008


> >  What's the most "pythonic" way to make this work?
> 
> class BaseClass(object):
>   def __init__(self, x, y, z, foo='foo'): # whatever
>      # etc
> 
> class SubClass(BaseClass):
>   def __init__(self, t, *args, **kw):
>     BaseClass.__init__(self, *args, **kw)
>     # do something with t
> 
> This does mean that the special sub class argument has to come before
> the base class arguments when you create instances.
> 
> Whether you call BaseCla

Thank you...  Excellent idea.  

I haven't tried it yet, but I suppose **kwarg.pop()'ing  and *args manipulation could help ease subclass instantiation call signature limitations. (?)

Thanks,
:)



      ____________________________________________________________________________________
Looking for last minute shopping deals?  
Find them fast with Yahoo! Search.  http://tools.search.yahoo.com/newsearch/category.php?category=shopping



More information about the Tutor mailing list