Providing full interaction with the run time

Fredrik Lundh fredrik at pythonware.com
Sun Oct 29 06:41:00 EST 2006


Dale Strickland-Clark wrote:

> We have a system we're developing which runs as a server. It has an xml-rpc
> interface which I've extended to provide some debugging facilities. This
> has already proved very useful and will continue to be so as the system is
> prepared for live deployment.
> 
> The debugging interface attempts to emulate the Python interactive shell.
> You type expressions, you get an answer. You type statements, they get
> executed.
> 
> The problem is these two types of input are handled differently by Python.
> You don't seem to be able to pass statements (which includes assignments)
> and expressions through the same calls.
> 
> There are three keywords that support this type of function: EXEC, EVAL and
> COMPILE. We can ignore EXEC for this because it doesn't support saving and
> restoring a local environment and EVAL can do it better.

huh?  both exec and eval take optional execution contexts:

     http://effbot.org/pyref/eval.htm
     http://effbot.org/pyref/exec.htm

> Or am I going about this all wrong?

yes, you're trying to reinvent the "code" module (and badly, it seems 
;-).  see the library reference to details, this page for some examples:

     http://www.effbot.org/librarybook/code.htm

</F>




More information about the Python-list mailing list