The future of Python immutability
steve at REMOVE-THIS-cybersource.com.au
Sun Sep 6 01:38:29 CEST 2009
On Sat, 05 Sep 2009 14:09:57 -0700, Adam Skutt wrote:
>> Python does not have lambda objects. It has lambda expressions that
>> produce function objects identical except for .__name__ to the
>> equivalent def statement output.
> Sure sounds like python has lambda objects to me then... the fact
> they're a special case of some more general construct is mostly
> semantics, /especially/ in the context of the point I was actually
> making, no?
No. Lambdas are a *syntactical construct*, not an object. You wouldn't
talk about "while objects" and "if objects" and "comment objects"
*because they're not objects*. Neither are lambdas -- they're syntax,
which creates ordinary functions:
>>> def f(x):
... return x
>>> g = lambda x: x
>>> type(f) is type(g)
Functions created with def and functions created with lambda are
*precisely* the same type of object. There is no such thing as a "lambda
object" which is a "special case" of ordinary functions, there are just
More information about the Python-list