function access to caller's symbols?

Alex Martelli aleaxit at
Sat Mar 10 00:12:04 CET 2001

"Lance E Sloan" <lsloan at> wrote in message
news:mailman.984165207.5080.python-list at
> I'm a Python newbie, so if I'm approaching this problem
> the wrong way, let me know.
> So, how can I make my function access its caller's
> symbol table?

This is indeed an unnecessarily complicated approach in
most cases (though you can access the caller's global
symbols by raising and catching an exception, and using
the resulting traceback object to walk the stack).  I would
strongly suggest NOT using such black-magic tricks, by
making the directory arg not optional -- the caller may
very well pass globals() explicitly if it wants.


More information about the Python-list mailing list