how can I use exec with main module globals?

Akathorn Greyhat akathorn at gmail.com
Sat Jul 12 21:15:36 CEST 2008


Hello, this is my first message in the group.

I'm spanish so my english sometimes is really bad, sorry =(

I have a problem and I hope someone has the answer.

I'm trying to make an in-game python idle, it works great but the exec
statement can't access the main module globals but only the ones that are
inside the module in wich I defined the function.

    def execute(self, string):
        exec(string, globals(), globals())

I realized that if I move the code to the main module, It works, but I want
it to be inside another script.

So my question is, how can I make the exec statement access the main
globals?

Thanks,
Akathorn Greyhat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080712/4a1c8e18/attachment.html>


More information about the Python-list mailing list