Symbols as parameters?
Martin.Drautzburg at web.de
Fri Jan 22 20:16:31 CET 2010
Mark Dickinson wrote:
> On Jan 21, 10:57 pm, Martin Drautzburg <Martin.Drautzb... at web.de>
>> 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.
More information about the Python-list