Would Anonymous Functions Help in Learning Programming/Python?

Bryan Olson fakeaddress at nowhere.org
Sat Sep 22 12:50:20 EDT 2007


chris.monsanto at gmail.com wrote:
> There are already anonymous functions in Python.
> 
> lambda x, y, z: x + y + z
> 
> is the same as:
> 
> def _(x, y, z): return x + y + z

They are the same only in special cases:

     The special identifier "_" is used in the interactive
     interpreter to store the result of the last evaluation; it
     is stored in the __builtin__ module. When not in interactive
     mode, "_" has no special meaning and is not defined.
     [Python Reference Manual; 2.3.2 Reserved classes of
     identifiers. http://docs.python.org/ref/id-classes.html]


-- 
--Bryan



More information about the Python-list mailing list