The future of Python immutability

Steven D'Aprano steven at REMOVE.THIS.cybersource.com.au
Mon Sep 7 00:32:12 EDT 2009


On Sun, 06 Sep 2009 10:12:56 -0400, Terry Reedy wrote:

> Adam Skutt wrote:

>> There's nothing inappropriate about using a lambda for a function I
>> don't care to give a name.  That's the entire reason they exist.
> 
> But you did give a name -- 'b' -- and that is when a lambda expression
> is inappropriate and when a def statement should be used instead


I think that's too strong a claim. Functions are first class objects, and 
there no reason why you can't do this:

def f():
    return None

g = f

So what's wrong with doing this?

g = lambda: None



>>> The idea that Python has 'lambda objects' had caused no end of
>>> mischief over the years.
>> As near as I can tell, this is because you're insisting on creating a
>> semantic distinction where there just isn't one.
> 
> To the contrary, I am objecting to the spurious distinction 'lambda
> object' as people often use it.


Agreed.



-- 
Steven



More information about the Python-list mailing list