closures and dynamic binding

Paul Boddie paul at boddie.org.uk
Mon Sep 29 20:51:15 CEST 2008


On 29 Sep, 19:26, Terry Reedy <tjre... at udel.edu> wrote:
>
> Please: Python does not have 'lambda functions'.  Def statements and
> lambda expressions both define instances of the function class.  So this
> amounts to saying "functions are subject to the same caveats as functions."

I myself am aware of the nature of "lambda expressions", for want of a
better term, but it's important to emphasise their nature to anyone
reading who isn't fully aware of what they represent. My closing
paragraph touches on the issues of readability and programmer
expectation when I write that 'function definition statements do not
behave like, say, "for", "if" or "while" statements'. Although this
may seem obvious, a newcomer might overlook lambda expressions in this
regard.

Personally, I'm not a great enthusiast of closures, anyway. Perhaps I
spent too long writing Java to be able to look at them as being
anything other than a fairly imprecise way of encapsulating state in a
callable.

Paul



More information about the Python-list mailing list