Nevertheless, any modifications to locals() are utterly futile (within a function).
Evil hack that makes modifications to locals() not quite as futile:
py> import sys py> import ctypes py> def f(): ... x = 1 ... locals()['x'] = 2 ... ctypes.pythonapi.PyFrame_LocalsToFast( ... ctypes.py_object(sys._getframe()), 0) ... return x ... py> f() 2
Warning! NEVER do this! ;)
(Also note that you can't del or add variables in this manner -- only modify them.)
Steve -- http://mail.python.org/mailman/listinfo/python-list