Securing a future for anonymous functions in Python
Nick Coghlan
ncoghlan at iinet.net.au
Fri Jan 7 11:00:50 EST 2005
Jacek Generowicz wrote:
> [*] Funnily enough, getting them to understand that "lambda x: fn(x)"
> is just a very silly way of writing "fn", can be quite a struggle
> at times ... but that's probably a consequence of the context in
> which lambda is introduced.
If you genuinely taught them that, you may have done them a disservice:
Py> def f(x):
... print x
...
Py> f1 = f
Py> f2 = lambda x: f(x)
Py> f1("hi")
hi
Py> f2("hi")
hi
Py> def f(x):
... print x * 2
...
Py> f1("hi")
hi
Py> f2("hi")
hihi
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at email.com | Brisbane, Australia
---------------------------------------------------------------
http://boredomandlaziness.skystorm.net
More information about the Python-list
mailing list