question about function pointer

Arnaud Delobelle arnodel at gmail.com
Fri Feb 17 03:00:54 EST 2012


On 17 February 2012 07:53, Zheng Li <dllizheng at gmail.com> wrote:
> def method1(a = None):
>        print a
>
> i can call it by
> method1(*(), **{'a' : 1})
>
> I am just curious why it works and how it works?
> and what do *() and **{'a' : 1} mean?
>
> when I type *() in python shell, error below happens
>
>  File "<stdin>", line 1
>    *()
>    ^
> SyntaxError: invalid syntax

It's worth reading the Python tutorial.  Here's the relevant section:

http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists

You could read all of 4.7

-- 
Arnaud



More information about the Python-list mailing list