How to with **kw

Stephen Coursen talon at coursen.ifu.net
Wed Jan 5 22:22:21 EST 2000


On Thu, 06 Jan 2000 02:49:22 GMT, wiktor1325 at my-deja.com
<wiktor1325 at my-deja.com> wrote:
>Is there a way to pass **kw args from
>one function to another,like:
>
>def func1(**kw):
>  for key in kw.keys():
>     print key
>
>def func2(**kw):
>  a_way_to_call_func1_with(kw)
>
>thanks in advance
>
Something like this will work:

>>> def func1( dict={}, **kws ):
...     for key in dict.keys( ):
...             print key
...     for key in kws.keys( ):
...             print key
...
>>> def func2( **kws ):
...     func1( kws, another_key='some_value' )
...
>>> func2( key_1='hello', key_2='world' )
key_2
key_1
another_key

HTH,
Steve

>Wiktor Sadowski
>
>
>Sent via Deja.com http://www.deja.com/
>Before you buy.


-- 
--
Stephen Coursen                      talon at coursen.ifu.net
Q:  How many supply-siders does it take to change a light bulb?
A:  None.  The darkness will cause the light bulb to change by itself.



More information about the Python-list mailing list