En Tue, 28 Jul 2009 03:21:10 -0300, Paul Johnston <paul....@gmail.com> escribió:

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?

In CPython, you may use sys._getframe(1).f_globals['__name__'] but I don't know how portable is that across Python implementations.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to