A critic of Guido's blog on Python's lambda

Michele Simionato michele.simionato at gmail.com
Fri May 12 03:19:42 EDT 2006


jayessay wrote:
> "Michele Simionato" <michele.simionato at gmail.com> writes:
> I can't get this to work at all - syntax errors (presumably you must
> have 2.5?, I only have 2.4).

You can download Python 2.5 from www.python.org, but the important bit,
i.e. the use of threading.local to get thread-local variables is
already there in Python 2.4.
'with' gives you just a nicer lisp-like syntax.

> This has not so much to do with WITH as relying on a special "global"
> object which you must reference specially, which keeps track (more or
> less) of its attribute values, which you use as "faked up" variables.
> Actually you probably need to hack this a bit more to even get that as
> it doesn't appear to stack the values beyond a single level.

Yes, but it would not be difficult, I would just instantiate
threading.local inside
the __init__ method of the dynamically_scoped class, so each 'with'
block
would have its own variables (and I should change getvar and setvar a
bit).

I was interested in a proof of concept, to show that Python can emulate
Lisp
special variables with no big effort.

  Michele Simionato




More information about the Python-list mailing list