Mailing List Archive

load .py file in interpreter?
Once you're running in the interpreter, how do you load (or re-load)
some foo.py Python code into the interpreter? (I'm using JPython, by the
way.)

This seems like something basic for interactive development. I must be
missing something obvious.

--
Joe Bowbeer
load .py file in interpreter? [ In reply to ]
I found it:

execfile("foo.py")

Joe Bowbeer wrote:

> Once you're running in the interpreter, how do you load (or re-load)
> some foo.py Python code into the interpreter? (I'm using JPython, by the
> way.)
>
> This seems like something basic for interactive development. I must be
> missing something obvious.
load .py file in interpreter? [ In reply to ]
Joe> Once you're running in the interpreter, how do you load (or
Joe> re-load) some foo.py Python code into the interpreter? (I'm using
Joe> JPython, by the way.)

Joe,

Check out the import statement and the reload function as well as the
execfile function you found. Both import and reload are used to import (or
reimport) a module into the current namespace.

Skip Montanaro | http://www.mojam.com/
skip@mojam.com | http://www.musi-cal.com/~skip/
847-971-7098