[IPython-user] python vs. ipython

Fernando Perez Fernando.Perez at colorado.edu
Tue Oct 25 11:47:25 CDT 2005


Peter Teuben wrote:
> A few months ago Johann Cohen Tanugi was asking the list about his problems 
> parsing the command line options after the filename on an ipython shell command 
> viz.
>  	ipython -i AngDistSampler.py -k 62.5 --draw
> to which Fernando's reply was to use
>  	ipython
>  	>>> run AngDistSampler.py -k 62.5 --draw
> instead.   I'm struggling with the same concept, in converting
> some classic python work of this nature into ipython and giving
> then control to ipython, i.e. the user.
> The man page clearly suggests that with
>  	ipython [options] files...
> the command line option handling is very different from that
> in python
>  	python [options] script [arguments]
> However, like Johann I still a little opaque how i should convert
> my typical python examples into ipython. Most of mine do some
> kind of
>  	python -i script options_for_script

The easiest way to think of it is simply that you start ipython _once_, and 
then use

run yourscript.py --option1 --option2 arg1 arg2

as many times as needed, as you make changes (typically in an editor open in 
another window) to yourscript.py.  Everytime yourscript.py runs, is similar to 
making a call to

python -i yourscript.py ...

but without having to fully reload all modules from scratch (which for large 
and complex modules can be O(minutes) ).  You also maintain the history of 
things in memory

You need to be careful if yourscript imports things which you are also 
modifying, due to the nature of python's import statement.  There have been 
discussions in the past on this topic.

Does this clarify things for you, or do you need further info?



More information about the IPython-user mailing list