func(*params)
Fredrik Lundh
fredrik at pythonware.com
Fri Nov 18 16:51:02 EST 2005
David Duerrenmatt wrote:
> For some reasons, I've to use Python 1.5.2 and am looking for a workaround:
>
> In newer Python versions, I can call a function this way:
>
> func = some_function
> func(*params)
>
> Then, the list/tuple named params will automatically be "expanded" and
> n=len(params) arguments will be submitted.
>
> Python 1.5.2 doesn't support this kind of function call.
use
apply(func, params)
or
result = apply(func, params)
more info:
>>> help(apply)
Help on built-in function apply in module __builtin__:
apply(...)
apply(object[, args[, kwargs]]) -> value
Call a callable object with positional arguments taken from the tuple args,
and keyword arguments taken from the optional dictionary kwargs.
Note that classes are callable, as are instances with a __call__() method.
Deprecated since release 2.3. Instead, use the extended call syntax:
function(*args, **keywords).
</F>
More information about the Python-list
mailing list