locals is a built in function that returns a dictionary of local values. The documentation says:
Warning
The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter.
Unfortunately, exec has the same problem in Python 3.0. Is there any way round this?
Use Case
Consider:
@depends("a", "b", "c", "d", "e", "f")
def test():
put_into_locals(test.dependencies)
depends stores the strings provided in its arguments in a list test.dependences
. These strings are keys in a dictionary d
. I would like to be able to able to write put_into_locals
so that we could pull the values out of d
and put them into the locals. Is this possible?