compiling to python byte codes

Jeremy Bowers jerf at jerf.org
Thu Sep 2 20:00:38 EDT 2004


On Thu, 02 Sep 2004 23:10:11 +0000, Maurice LING wrote:
> Can I feed a python source file into compile(), line by line, and expect 
> it to generate a working .pyc file? I suppose my intended use is to be 
> able to handle python codes written at run time, to execute python codes 
> line by line, in a python program. It is somewhat like a tracer routine 
> that can interpret a line of python code, read out the variables, before 
> going to the next line of python code. Can compile() do this, or do I 
> have to use pexpect to run an instance of python?

Why don't you clearly spell out your intended use and ask about that,
instead?

If, based on your use of "I suppose" and "somewhat", you are still unclear
on your intended use, figuring that out would be step #1. :-)

Many good modules exist for many things already; if you're trying to trace
for instance, there is a module for that. Let's start at the beginning:
What are you trying to do?




More information about the Python-list mailing list