From: Ype K. <yk...@xs...> - 2001-09-05 19:09:30
|
Dimo, > >I am running into problems using the app subclass interact.py. >I would like the user to be able to enter jython language at the interactive prompt (not the >>> jython prompt, but the shell prompt created by interact.py), and have the language interpreted and executed appropriately. >To achieve this, in the InteractiveApp evalCommand method I'm using exec and eval on the user-entered commands. > >The problem is that I can't maintain continuity between separate commands. >For example, >prompt/> a = 3 >prompt/> b = a >uncaught: (<class exceptions.NameError... >... >NameError: a > >So there seems to be some namespace issue whereby I can't store the variables in the shell. >Is what I'm attempting to do possible using interact.py? I've never seen interact.py so I hope this is right: You need to pass globals/locals to the exec.... function being called. These constitute the namespace in which the exec.... function is executed. They are dictionaries mapping identifiers to values. Have fun, Ype |