Dynamical scoping

Paul Rubin http
Tue Jan 15 19:14:03 CET 2008

Kay Schluehr <kay.schluehr at gmx.net> writes:
> On 15 Jan., 02:13, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> > George Sakkis <george.sak... at gmail.com> writes:
> > > What's the best way to simulate dynamically scoped variables ala Lisp ?
> >
> > Ugh.... check the docs for the python 2.5 "with" statement, which
> > gives you sort of a programmable unwind-protect (more powerful than
> > try/except).  You'd have an environment dictionary and use the "with"
> > statement to maintain a stack of shallow-binding cells like in an
> > old-time lisp system, automatically unwinding when the "with" suite
> > finishes.  The whole concept sounds hopelessly crufty--I think nobody
> > even does it that way in Lisp any more, you're better off passing an
> > environment around explicitly.  If there were a lot of variables, this
> > could be a good application for functional maps, which I've been wanting
> > to implemetn for python.

Kay, did you have something to add?  You quoted the above two posts
and then your message stopped.

More information about the Python-list mailing list