Yes, Russell, what you suggested works.
I have to chew more on the syntax to see how this is working.
because in the book that I have, it says:
exec code [ in globaldict [, localdict] ]
The [] indicate the last two parts are optional. If you don't supply them, exec just uses the current namespace.
However, as others have said, you are much better off using a separate dictionary for such values, rather than stuffing them into the local variables:
user_vars = {} y = "a" user_vars[y] = 4
It keeps a clean separation between your variables and the user's variables, easily avoiding namespace conflicts.
Cheers, Nick.
-- Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia --------------------------------------------------------------- http://boredomandlaziness.skystorm.net -- http://mail.python.org/mailman/listinfo/python-list