No-brainer? Dictionary keys to variable name?

Christopher Myers chris.myers at ingenta.com
Fri Aug 2 16:22:52 EDT 2002


Thanks, all for your replies and help.

I have decided to do the following, and it works fine for me:

I kept the function definition with all the keyword arguments, with
defaults, and I call the function using 

function(**dict)

and it works nicely, and as I wanted.

Thanks again, all.

-C

Mark McEahern wrote:
> 
> [Steve Holden]
> > Perhaps I'm missing something, but with keyword arguments
> > providing default values, doesn't this get everything the OP wanted?
> 
> Not as far as I can tell.  The OP wants to define the func without
> specifying the arguments:
> 
>   def foo(**kwargs)
> 
> AND call the func with a dict:
> 
>   foo(**theDict)
> 
> AND presumably not have to initialize default values.
> 
> Talk about having your cake and eating it too, eh?
> 
> // m
> 
> -

-- 
Christopher Myers, Graduate Software Developer 
Ingenta, Inc.
12 Bassett St.
Providence, RI  02903
ph:  401.331.2014 x 102
em:  chris.myers at ingenta.com
aim: chrismyers001



More information about the Python-list mailing list