Something is rotten in Denmark...

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Jun 2 00:37:03 EDT 2011


On Wed, 01 Jun 2011 19:50:14 -0500, harrismh777 wrote:

> harrismh777 wrote:
>> Allow me to clarify... I'm not speaking about whether the lambda is
>> short-hand for def, ... that part of the docs I understand well!... no
>> problems there.
> 
> Allow me to clarify a little further...   the docs are misleading in
> that they state that the lambda can be coded (as an expression) where
> the def 'statement' cannot be coded.   Well, I know, this is speaking to
> the syntax rules not the binding rules, but the point is that it implies
> that the lambda can be used where the def cannot... 

And so it can.


> and this is where
> the hypnosis takes place... we assume that something 'additional' is
> happening with the lambda that is *not* happening with the def.

This is not a failure of the docs, but of your assumption. The only 
difference is that lambda is an expression , and is limited to a single 
expression. The leap from "lambda is an expression" to "...and therefore 
the thing created by lambda has 'additional' stuff beyond ordinary def 
functions" is unjustified.

Nevertheless, it does seem to be awfully common. You're hardly alone.



-- 
Steven



More information about the Python-list mailing list