combining several lambda equations

Steven Bethard steven.bethard at gmail.com
Fri Feb 18 12:26:38 EST 2005


Paddy McCarthy wrote:
> x=lambda : A < B
> y=lambda : C+6 >= 7
>
[snip]
>
> Z=lambda : (A<B) and (C+6>=7)

See "Inappropriate use of Lambda" in
http://www.python.org/moin/DubiousPython

Perhaps your real example is different, but notice that
     <name> = lambda <args>: <expr>
is equivalent to
     def <name>(<args>):
         return <expr>
except that the latter will give your function a useful name.  No reason 
to use the *anonymous* function construct to create a *named* function.

STeVe



More information about the Python-list mailing list