interactive interpreter

Chris Barker chrishbarker at home.net
Tue Oct 23 14:18:17 EDT 2001


Karol Makowski wrote:

> How to run myprogram.py in interactive interpreter?

depending on exactly what you mean, there are three options:

import myprogram.py

execfile("myprogram.py")

$python -i myprogram.py

I'm guessing you want the execfile option. That makes the namespace of
your program the main namespace, which makes it easiest to examine
values, etc when it's done running. import runs the code, but puts
everything into the modules namespace. running python with -i will run
the program, and then leave you with and interactive interpreter when
it's done. 

-Chris


-- 
Christopher Barker,
Ph.D.                                                           
ChrisHBarker at home.net                 ---           ---           ---
http://members.home.net/barkerlohmann ---@@       -----@@       -----@@
                                   ------@@@     ------@@@     ------@@@
Oil Spill Modeling                ------   @    ------   @   ------   @
Water Resources Engineering       -------      ---------     --------    
Coastal and Fluvial Hydrodynamics --------------------------------------
------------------------------------------------------------------------



More information about the Python-list mailing list