Parameter passing in python

Jacob Hallen jacob at hq.workspot.com
Thu May 31 18:08:05 EDT 2001


Alex Martelli wrote:
> 
> "Laura Creighton" <lac at cd.chalmers.se> wrote in message
> news:mailman.991320527.18316.python-list at python.org...
> > (posted by me, but this is from all of us here .... )
> >
> > ---------------------------------------
> > This is what I have to do in my code when inheriting widgets:
> >
> > import Pmw
> >
> > class MyButtonBox(Pmw.ButtonBox)
> >     def __init__(self, parent, **kw):
> >        ...
> >         apply(Pmw.ButtonBox.__init__, (self, parent), kw)
> >
> > Why am I required to do apply to be able to pass the keyword list?
> > Some model of Pmw.ButtonBox.__init__(self, args) would be
> > more readable.
> 
> In Python 2,
>         Pmw.ButtonBox.__init__(self, parent, **kw)
> is equivalent to the apply you have written.
> 
> Maybe the docs don't mention it because they go back
> to pre-Python-2 times...?
> 
> Alex

This does indeed work. Thanks!

However there is no mention at all of this in the Python Reference
Manual. I have checked both the 2.0 and 2.1 versions. It ought to
be in section 5.3.4, as far as I can understand.

Jacob Hallen
AB Strakt



More information about the Python-list mailing list