How to use imported function to get current globals
Dave Angel
davea at davea.name
Sat Jun 7 22:24:08 EDT 2014
1989lzhh <1989lzhh at gmail.com> Wrote in message:
> Here is the code
> m1.py
> def f():
> print globals()
>
> m2.py
> from m1 import f
> f()# how to get current module's globals?
>
As others have said, it's probably a bad idea. I can think of 3
reasons to try: teacher said so, writing a debugger,
transliterating code from a crude language into python.
Could you elaborate on what you really want? Which of those two
modules is your main script? Which code in which module is trying
to get which module's globals? And is the connection static or
dynamic? And do you want a snapshot of them, or to be able to
modify and track changes?
--
DaveA
More information about the Python-list
mailing list