greenarrow / magnetism

Magnetism is an easy to use environment for writing and running simple useful scripts to do useful things on your desktop.
http://greenarrow.github.com/magnetism
1 stars 0 forks source link

Modules imported withing a magnetism script do not exist in the context of functions defined within the script #4

Open greenarrow opened 14 years ago

greenarrow commented 14 years ago

Imported modules work correctly in the main body of a script but not within a function. Must be due to the way exec operates...

Workaround: Import the module within the function

greenarrow commented 14 years ago

This has been shown to be a more general difference in variable scope for code execute by exec(). It looks like higher levels are not looked up to when the variable is not found in the local scope. At present the global statement must be used in all cases.