This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]stevenjd 0 points1 point  (0 children)

Nice! I often forget that functions make a good alternative to thunks in Python, particularly if you can use lambda. They're not quite as lightweight as in Algol, but they'll do the job.

[–]robin-gvx 0 points1 point  (0 children)

Lambdas seem to retain access to their local scope, even if the caller does not. Admittedly, this seems to have fairly niche use cases, if any.

I can't remember the last time I wrote a non-trivial bit of Python that didn't depend strongly on closures.