I actually want to create a new local. I know it sounds dubious, but I think I have a nice use case for this. Essentially my problem is that this code throws "NameError: global name 'eggs' is not defined" when I try to print eggs:
def f():
import inspect
frame_who_called = inspect.stack()[1][0]
frame_who_called.f_locals['eggs'] = 123
def g():
f()
print(eggs)
g()
I found this old thing: http://mail.python.org/pipermail/python-dev/2005-January/051018.html
Which would mean I might be able to do it using ctypes and calling some secret function, though they only talked about updating a value. But maybe there's an easier way?