Keyword Arguments

Fredrik Lundh fredrik at pythonware.com
Sat Nov 15 08:59:35 EST 2003


"Ryan" wrote:

> How can I use the value of a variable to represent a keyword in a function call?
>
> For example:
>
> def foo(**kwargs):
>     kwargs = **kwargs
>
>
> item = "temperature"
>
> foo(item=25.5)
>
> I would like the keyword to be the value of item which is temperature.
> Is this possible?

    foo(**{item: 25.5})

</F>








More information about the Python-list mailing list