Determining __name__ from the code that called a function

Paul Johnston paul.paj at
Tue Jul 28 08:21:10 CEST 2009


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,


More information about the Python-list mailing list