Providing full interaction with the run time
fredrik at pythonware.com
Sun Oct 29 12:41:00 CET 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
> 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:
> 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:
More information about the Python-list