[Tutor] Tkinter Q's
Sandip Bhattacharya
sandip at lug-delhi.org
Wed Jul 13 23:54:12 CEST 2005
Joseph Quigley wrote:
> Hi,
> what's the **kw stand for, used for? What does it mean?
>
>
[...]
>>
>>class Main(Frame):
>> def __init__(self, master=None, **kw):
>> Frame.__init__(self, master, **kw)
>>
It is the python way to pass along all keyword arguments (xxx=yyy).
So in the above if Main was instantiated the following way:
myframe = Main(name="some name", height="100")
Then __init__ gets called with parameters:
__init__(self,None, name="some name", height="100")
The **kw here denotes the name and height keywords.
Therefore Frame.__init__ is called with:
__init__(self,None, name="some name", height="100")
Without **kw, there is no other way to send an arbitary number of
parameters to Frame.__init__.
- Sandip
--
Sandip Bhattacharya * Puroga Technologies * sandip at puroga.com
Work: http://www.puroga.com * Home/Blog: http://www.sandipb.net/blog
PGP/GPG Signature: 51A4 6C57 4BC6 8C82 6A65 AE78 B1A1 2280 A129 0FF3
More information about the Tutor
mailing list