Simple prototyping in Python

Michael Geary Mike at DeleteThis.Geary.com
Tue May 4 23:25:25 EDT 2004


> > Greg Ewing wrote:
> >>BTW, IMO [the closure] is a seriously warped technique
> >>that I would never use, even in Javascript. I can't see any
> >>benefit in it that's anywhere near worth the obfuscation.

> Michael Geary wrote:
> > I think part of the problem is the contrived examples that
> > we all use to illustrate closures.

Greg wrote:
> Just in case it wasn't clear, I was talking about that
> particular use of a closure, i.e. simulating an object
> with a private instance variable. I'm well aware that
> there are other, better uses for closures.
>
> The example you posted is a reasonable use of
> closures (although the in-line-constructed object
> passed as an argument to a function made my brain
> hurt a bit while trying to parse it!)

Ah, roger that. Naturally, it's also possible to write that code by creating
the events object first and then just passing a reference to it into the
function call--it sounds like that would make it easier to read.

-Mike





More information about the Python-list mailing list