Newbie edit/compile/run cycle question

Bruno Desthuilliers bdesth.quelquechose at free.quelquepart.fr
Sat Dec 8 14:53:40 EST 2007


MartinRinehart at gmail.com a écrit :
> I'm a java guy used to the effective edit/run cycle you get with a
> good IDE.
> 
> Today I'm writing my first Python, but can't seem to find the way to
> use Python's inherent edit/run cycle.
> 
> I edit my source, import it into Python, run it. Fine. Then I edit
> again, but the next import doesn't notice that a new compile is
> needed.

This is not an accurate definition of what happens. The import mechanism 
   keeps already imported modules in cache (for obvious reasons). wrt/
"notice(ing) a new compile is needed", it's not the import mechanism's 
duty, but the VM one's.

> I'm making a little progress (very little) by exiting/
> reentering Python after each edit. Ugh.

Java doesn't have an interactive shell, so there's no real parallel 
here, but anyway: with Java, you have to restart a Java VM each time you 
run your code. Why do you hope something else with Python ?

> What don't I know that I should know to just edit/run,

Do what you would do with Java:

$ python yourprogram.py

Or if you want to inspect the state after execution (something you can't 
do with Java):

$ python -i yourprogram.py


> preferably at
> the tap of a function key?

Use an IDE then. Or a real code editor like emacs - it's python-mode is 
way more powerful than what I saw in any IDE.



More information about the Python-list mailing list