How can I exec() in global?

Jerald jfj at freemail.gr
Sun Sep 12 06:17:02 CEST 2004


Hi.

Is it possible to exec() from within a function so the exec'd
code affects global?

For example

def foo():
     exec ('X=[1,2,3]')

And I'd like 'X' to be a global variable.


Thanks,

Gerald



More information about the Python-list mailing list