Mark Dickinson wrote: > On Jan 21, 10:57 pm, Martin Drautzburg <martin.drautzb...@web.de> > wrote: >> Here is a complete expample using a decorator, still a bit noisy >> >> def move(aDirection): >> print "moving " + aDirection >> >> #Here comes the decorator >> def scope(aDict): >> def save(locals): >> [...] > > Have you considered making 'scope' a context manager? Your > modifying-locals hacks could be put into the __enter__ and __exit__ > methods, and you'd use the context manager with something like: > > with scope(): > # ... > # use up, down, left, right here > > # up, down, left, right no longer defined after the with block exits.
Wow! no I wasn't aware of that. I found some refererences to the magical "with" statement, but I had the impressions that it was a future thing and not available in python 2.5. Other than that it looks exactly like what I was looking for. Thanks. -- http://mail.python.org/mailman/listinfo/python-list