Problem when calling __init__() in base class

Hans Nowak wurmy at earthlink.net
Mon Dec 3 16:44:55 EST 2001


"Sébastien Cabot" wrote:
> 
> (With Python2.1.1, on Debian, with Python megawidget)
> 
> We have the following in the class 'ScrolledFrame' of the Pmw.
> 
> class ScrolledFrame(Pmw.MegaWidget):
>     def __init__(self, parent = None, **kw):
>     ...
> 
> In my inherited class, I call __init__() of the base class
> 'Pmw.ScrolledFrame.'
> 
> class MyScrolledFrame(Pmw.ScrolledFrame):
>   def __init__(self, parent, **kw):
>     Pmw.ScrolledFrame.__init__(self, parent, kw)
>     ...

I think this should be:

    Pmw.ScrolledFrame.__init__(self, parent, **kw)

These are keyword arguments. If you pass them to another
function as 'kw', then you pass a dictionary. If you
pass them as **kw, to you act like you called the other
function with the same keyword arguments. It's syntactic
sugar for the apply() function.
   
--Hans



More information about the Python-list mailing list