The ** operator ambiguous?

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Mon Jul 16 14:13:09 EDT 2007


En Mon, 16 Jul 2007 14:40:14 -0300, Robert Dailey <rcdailey at gmail.com>  
escribió:

> I noticed that the ** operator is used as the power operator, however
> I've seen it used when passing variables into a function. For example,
> I was researching a way to combine dictionaries. I found that if you
> do this:
>
> a = {"t1":"a", "t2":"b"}
> b = {"t3":"c"}
> dict( a, **b )
>
>
> This combines the two dictionaries. However, I have no idea what the
> ** operator is here. I know that when you specify ** as a parameter in
> a function definition, it represents a dictionary of parameters passed
> in. However, in this example it is NOT being used in a function
> definition. It is being used when passing variables into a function.
> Can someone explain what this means? I looked in the documentation but
> I couldn't find anything.

See this section in the tutorial  
<http://docs.python.org/tut/node6.html#SECTION006700000000000000000>.
If you want the dirty details: <http://docs.python.org/ref/calls.html>

-- 
Gabriel Genellina




More information about the Python-list mailing list