Calling a function with unknown arguments?

Rob crowell at mit.edu
Wed Mar 7 20:15:47 EST 2007


> You can do this with a list comprehension:
> bob(*[possible[k] for k in bob2.func_code.co_varnames])
>
> The LC creates a list of arg values in the same order as the var names
> for the function. Putting a * before the list when you call bob()
> turns that list into it's arguments.

Thanks Tom! This turns out to be exactly what I needed.




More information about the Python-list mailing list