compiling to python byte codes

Maurice LING mauriceling at
Fri Sep 3 02:48:55 CEST 2004

Jeremy Bowers wrote:
> 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?

I am using SBML (system biology markup language) as a front-end 
modelling language for my project. And for ease of further maintenance 
of the model and interoperability purposes, my project requires me to 
convert it into an intermediate form (MA), which is somewhat assembly is 
structure, as in, each instruction takes the form of <opcode> 
<operand>*. Here I am, attempting to write a virtual machine that can 
run MA, using python. So, it becomes a MA virtual machine running on 
python virtual machine.

My concern is, is it simpler to convert MA to python codes or python 
bytecodes. What are the pros and cons? Assuming that to convert to 
python source code is a choice, I'm thinking that MA virtual machine can 
then read a MA instruction and output the corresponding python source 
codes, but are there facilities in python to run python codes, line by 
line, as it is being thrown out by MA virtual machine?

As a side note, does anyone think that this project might be suitable 
enough to apply for PSF Grant?


Maurice Han Tong LING, BSc(Hons)(MCB), AdvDipComp, SSN, FIFA
Doctor of Philosophy (Science) Candidate, The University of Melbourne
mobile: +61 4 22781753
	+65 96669233
mailing address: Department of Zoology, The University of Melbourne
		 Royal Parade, Parkville, Victoria 3010, Australia
residential address: 9/41 Dover Street
	   	     Flemington, Victoria 3031, Australia
email: mauriceling at

The information contained in this message, including its attachment(s),
is CONFIDENTIAL and solely intended to its addressee(s) only. The
content of this message, including its attachment(s),  may be subjected
to copyright and privacy laws. If you have received this email in error,
please let me know by returning this email, and then destroy all copies.

"I cannot discover anyone knows enough to say definitely what is
and what is not possible" -Henry Ford
"The difference between the impossible and the possible lies
in a person's determination" -Tommy Charles Lasorda

More information about the Python-list mailing list