access interactive namespace from module (shared namespace?)
David C. Ullrich
dullrich at sprynet.com
Sun May 25 07:54:51 EDT 2008
On Sun, 25 May 2008 03:32:30 -0700 (PDT), ulrich at dorda.net wrote:
>Thanks for the reply,
>
>Of course the suggested solution is working and good, but a bit
>complicated. The module/function where i need to access the variable
>value from the interactive shell is burried quite deep and I would
>nedd to hand the locals() quite often from one module to another.
>Furthermore it makes the call function slightly more complicated, as
>the locals()-argunment has to be given every time.
>
>I was hoping for something a bit different: If I wanted to access a
>value b from another module "utest2.py", I would simply need to type
>in utest.py: import utest2; print 2*utest2.b
>Isn't there a name for the interactive namespace (like here the
>utest2), which I can use to access the variable without handing the
>whole dictionary?
"""utest.py"""
import __main__
def doit():
print 2*__main__.a
>Cheers,
>
>Ulrich
>
>
David C. Ullrich
More information about the Python-list
mailing list