Running autogenerated code in another python instance

Bengt Richter bokr at oz.net
Wed Nov 2 01:33:28 EST 2005


On Wed, 2 Nov 2005 06:08:22 +0000 (UTC), Paul Cochrane <cochrane at shake56.esscc.uq.edu.au> wrote:

>Hi all,
>
>I've got an application that I'm writing that autogenerates python code
>which I then execute with exec().  I know that this is not the best way to
>run things, and I'm not 100% sure as to what I really should do.  I've had a
>look through Programming Python and the Python Cookbook, which have given me
>ideas, but nothing has gelled yet, so I thought I'd put the question to the
>community.  But first, let me be a little more detailed in what I want to
>do:
>
[...]
>
>Any help or advice would be really (really!) appreciated.
>
It's a little hard to tell without knowing more about your
user input (command language?) syntax that is translated to
or feeds the process that "autogenerates python code".

E.g., is it a limited python subset that you are accepting as input,
or a command language that you might implement using the cmd module, or ?
There are lots of easy things you could do without generating and exec-ing
python code per se. How complex is a user session state? What modifies it?
What actions are possible? History? Undo? Is the data a static passive
resource to view, or partly generated or made accessible by prior actions
in a session? Single user or collaborative? Shared access to everything or
only to static data? Etc., etc.

Some examples of user input and corresponding generated python might help,
with some idea of the kind of visualization aspects being controlled ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list