Simple prototyping in Python

Greg Ewing greg at cosc.canterbury.ac.nz
Tue May 4 22:48:05 EDT 2004


Michael Geary wrote:
> 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.
> 
> I think part of the problem is the contrived examples that we all use to
> illustrate closures.

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!)

-- 
Greg Ewing, Computer Science Dept,
University of Canterbury,	
Christchurch, New Zealand
http://www.cosc.canterbury.ac.nz/~greg




More information about the Python-list mailing list