Symbols as parameters?
Mark Dickinson
dickinsm at gmail.com
Fri Jan 22 07:34:06 EST 2010
On Jan 21, 10:57 pm, Martin Drautzburg <Martin.Drautzb... at 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.
--
Mark
More information about the Python-list
mailing list