Good question, and indeed not very nice. The thing is that the exec() command a few lines later gets globals() as the dictionary to work with. I guess I could change that as well. Perhaps locals() will do as well; otherwise I could set-up a dedicated dictionary with the required vars.