thanks all you guys. I have find the solution which is quite simple by using
sys._frame(1).f_locals in function to get the caller's scope
The following is my user case:
I am writing a tool to translate python code to cython code then compiled using
decorate.
jit, build=make("mymodule")
#jit func
On Sun, Jun 8, 2014 at 10:28 AM, 1989lzhh <1989l...@gmail.com> wrote:
>
>
> 发自我的 iPhone
>
>> 在 Jun 8, 2014,4:52,Chris Angelico 写道:
>>
>>> On Sun, Jun 8, 2014 at 3:40 AM, 1989lzhh <1989l...@gmail.com> wrote:
>>> Here is the code
>>> m1.py
>>> def f():
>>>print globals()
>>>
>>> m2.py
>>> from m
发自我的 iPhone
> 在 Jun 8, 2014,4:52,Chris Angelico 写道:
>
>> On Sun, Jun 8, 2014 at 3: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?
>
> As Ian said, you almos
On 6/7/14 1:40 PM, 1989lzhh 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?
Looking at the code you have posted in your two messages so far, it
seems like you are building something very interesting and ambitious.
On Sun, Jun 8, 2014 at 3: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?
As Ian said, you almost certainly do not want to do this. But if you
have a solid use-case that
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.p
Here is the code
m1.py
def f():
print globals()
m2.py
from m1 import f
f()# how to get current module's globals?
--
https://mail.python.org/mailman/listinfo/python-list