Thank you Kent. That worked.
============

André Roberge wrote:

/ I have a "robot" that can do some actions like "move()" and
/>/ "turn_left()". I can program this robot using python like this:
/>/ ====
/>/ .def move_and_turn():
[snip]//
/>/ The question I have is: how do I do this with an explicit dictionary.
/>/ I would *guess* that this is somehow equivalent to "how do I create a />/ dictionary that has access only to robot instructions [move(), />/ turn_left(), etc.] and Python's basic syntax" ... but I don't know how />/ to do this.
/
myGlobals = { 'move':move, 'turn_left':turn_left }
exec code in myGlobals


You don't need to add built-ins to myGlobals. Add whatever of your symbols you want the code to have access to.

Kent


_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor

Reply via email to