dynamic argument name for functions
Simon Brunning
simon at brunningonline.net
Fri Jan 12 15:22:04 EST 2007
On 1/12/07, mark <rkmr.em at gmail.com> wrote:
> I want to pass a value to an argument of a function. The argument name is
> dynamic and is stored in a
> variable. How do I call the function using with arg_name and value as the
> parameters.
> thanks
> mark
>
> For ex:
> def function(arg1='None', arg2='None', arg3='None'):
> print arg1
> print arg2
> print arg3
>
>
> arg_name = 'arg1'
> arg_value = 'i am passing a value to argument 1'
> function(???????)
Untested:
function(**{arg_name: arg_value})
--
Cheers,
Simon B
simon at brunningonline.net
More information about the Python-list
mailing list