Is this possible: scoping question with exec
Tim Peters
tim.one at home.com
Fri Aug 24 16:04:42 EDT 2001
[Emile van Sebille]
> exec(a.func_code, {'b':4})
Ouch! Emile, stop doing that. Use
exec a.func_code in {'b': 4}
[Bengt Richter]
> That seems to work, but where is that form of exec statement documented?
It isn't, and is therefore undefined. Before Python 1.0, "exec" was a
builtin function rather than a statement. The ancient function form is
still accepted for backward compatibility, but that's been a secret <wink>
for nearly 8 years.
More information about the Python-list
mailing list