On Sat, Jun 7, 2014 at 11:40 AM, 1989lzhh <1989l...@gmail.com> wrote: > Here is the code > m1.py > def f(): > print globals() > > m2.py > from m1 import f > f()# how to get current module's globals?
Evaluate globals() in the current module and pass the resulting dict in as a parameter: # m1.py def f(globals): print globals # m2.py from m1 import f f(globals()) There's a code smell here, though. If your function really needs to interact with globals from other modules, then those should probably not be globals in the first place. More likely they should be attributes of objects that can be easily passed around. -- https://mail.python.org/mailman/listinfo/python-list