custom plugin architecture: how to see parent namespace?

escalation746 escalation746 at yahoo.com
Sun Jul 22 23:06:52 CEST 2007


faulkner wrote:

> sys._getframe(1).f_locals

Brilliant. That one's pretty well hidden and labeled "should be used
for internal and specialized purposes only". Guess I'm officially
special. :-)

To implement this with minimal requirements on the author of the
plugin, I created a function in master.py:
def GetKey():
    ns = sys._getframe(2).f_locals
    return ns['VALUABLE']

Now the plugin gets the useful info simply:
import master
print master.GetKey()

Though it would be nice if this info could somehow be "injected" into
the namespace of plugin.py without this, I can live with two lines.

Thanks!

-- robin




More information about the Python-list mailing list