Unrolling of actual parameters from list
Padraig at Linux.ie
Padraig at Linux.ie
Fri Jan 24 09:06:21 EST 2003
Roberto Cavada wrote:
> Hi there,
> consider this class definition:
>
> class Foo:
> def __init__(self, a, b):
> # do something
> return
> pass # end of class
>
> Suppose now you want to create a Foo instance by passing a *list* of
> actual parameters:
>
> l = [10,20]
> foo = Foo(l) # this - as you can guess - does not work
>
> Is there a way to do that?
foo = Foo(*l)
http://www.python.org/doc/current/ref/calls.html
Pádraig.
More information about the Python-list
mailing list