Re: Higher-order functions in Python?

Guido.van.Rossum@cwi.nl
Tue, 27 Sep 1994 13:57:28 +0100

> I've been rooting around in Python, and it doesn't seem to me that
> Python supports a notion of closures -- for implementing higher-order
> functions.
>
> While I'm not one of those lambda-calculus nuts, I do like using
> closure every now and then. If the answer to this request is "use
> objects", I'll be happy to do so. But I was wondering if this was a
> purposeful omission or not.

Indeed, the answer is "use obects". You can also get away with
default arguments sometimes (this is the recommended way to smuggle
selected bits of the calling scope into a lambda). I can't call it a
purposeful omission since I didn't even know what they were (having
always abhorred everything that even remotely smelled of Lisp :-) but
I don't think they would fit in well with the current language -- nor
that they are necessary. In a recent post of Dan Connolly on www-talk
he mentioned that closures were rather complicated beasts for
non-expert users (or something to that effect).

--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>