[IPython-user] ipython and optparse
Fernando.Perez at colorado.edu
Mon Aug 1 13:49:46 CDT 2005
Johann Cohen Tanugi wrote:
> I use optparse to parse command line args and it works fine with my
> python 2.4 install. I also have ipython built on top of it, and it works
> fine as well, but it seems to be a feature of ipython that *all* args
> are passed to it instead of some being passed to the python script for
> processing by optparse....
> python -i AngDistSampler.py -k 62.5 --draw
> works, but
> ipython2.4 -i AngDistSampler.py -k 62.5 --draw
> does not : ipython complaining that -k is not a known option.....
> thanks for any further information
The -i option is a python option, not an ipython one. For what you are trying
to do, the way to use ipython is:
In: run AngDistSampler.py -k 62.5 --draw
The ipython %run command will execute the script given, passing the rest of
the line to your program as sys.argv, as if it had been executed at the
It would be nice to implement -i correctly for ipython, though. Something like:
ipython -ipoption1 -ipoption2... -i foo.py --moreargsforfoo
the -i option would terminate ipython's options handling, and pass the rest of
the command line unmodified. This would be useful for those wanting to
benefit from ipython's enhanced tracebacks and pdb support, while requiring a
full restart of the interpreter (so that %run is not enough).
Feel free to file a request for this on the tracker if you think it's
important, so at least it doesn't get forgotten.
More information about the IPython-user