Determining __name__ from the code that called a function

Paul Johnston paul.paj at gmail.com
Tue Jul 28 02:21:10 EDT 2009


Hi,

In ToscaWidgets 2 experimental, when defining resources you often do
something like this:
CSSLink(modname=__name__, filename='static/mycss.css')

Now, what I'd like to do is make the "modname=__name__" optional, to
make code more concise. I figure there must be some way (using inspect
or something) to determine what __name__ would be in the code that
just called my function. Couldn't immediately see how to do this - any
suggestions? Thanks,

Paul



More information about the Python-list mailing list