Namespaces/introspection: collecting sql strings for validation
Alex Martelli
aleax at mac.com
Sun Apr 22 22:33:02 EDT 2007
Martin Drautzburg <Martin.Drautzburg at web.de> wrote:
...
> The problem is the first part: how can I lookup the callers module and
> the classobjs defined in there? Or finding any constant strings in the
> caller's module would also be just fine. Or is there a completely
> different way to do such a thing?
Don't do black magic in production code.
For just hacking around, see sys._getframe -- it can give you a frame
object from where you can introspect into your caller's globals -- and
the inspect module of the standard Python library.
But don't put such black magic in production. The completely different
way is: just don't.
Alex
More information about the Python-list
mailing list