[Tutor] apply() vs. the extended call syntax

Dave Angel davea at davea.name
Sat Aug 3 04:25:19 CEST 2013


Tim Johnson wrote:

> * Tim Johnson <tim at akwebsoft.com> [130802 15:41]:
> <...> Is there a cleaner way to do this? using apply()
>> looks so much simpler, but I understand it is not even available in
>> py 3 ....
>   def apl(funcall): funcall[0](*funcall[1])
>   k = "key2"
>   >>> apl(func_D[k])
>   I don't have an argument!
>   ## ??? :)
>

See  http://docs.python.org/2/library/functions.html#apply

The apply approach has been replaced by * and ** arguments, the former
for positional args, and the latter for keyword arguments.

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

-- 
DaveA



More information about the Tutor mailing list