H
Helmut Jarausch
Hi,
I'd like to give the user the ability to enter code which may only rebind
a given set of names but not all ones.
This does NOT work
A=1
B=2
Code=compile('A=7','','exec')
exec(Code,{'A':0})
print("I've got A={}".format(A)) # prints 1
How can 'filter' the gobal namespace such that modifying 'A' is allowed
but any attempt to modify 'B' should give an exception.
Many thanks for a hint,
Helmut.
I'd like to give the user the ability to enter code which may only rebind
a given set of names but not all ones.
This does NOT work
A=1
B=2
Code=compile('A=7','','exec')
exec(Code,{'A':0})
print("I've got A={}".format(A)) # prints 1
How can 'filter' the gobal namespace such that modifying 'A' is allowed
but any attempt to modify 'B' should give an exception.
Many thanks for a hint,
Helmut.