[IPython-user] from __future__ import division

Fernando Perez Fernando.Perez at colorado.edu
Mon Dec 19 22:14:17 CST 2005

skip at pobox.com wrote:
>     Fernando> As I mentioned in the next message, ...
> See my next message... ;-)

We probably crossed messages :)

>     >> The -Qnew flag isn't understood by IPython.  Is it possible to
>     >> support it?
>     Fernando> You need to pass it to the ipython starter file, as mentioned
>     Fernando> by Harri:
>     Fernando> On linux/unix you can fix this by changing ipython's first
>     Fernando> line to:
>     Fernando> #!/usr/bin/python2.3 -Qnew
> Ah, okay.  I must have missed that detail.  What about going a step further
> and (on Unix/Linux anyway) replacing the IPython starter file with a shell
> script that processes command line args that should be handled by Python
> proper, then invoking the regular interpreter with the various args the user
> passed in?

Well, the problem is that there is no real definition of 'command line args 
that should be handled by Python proper'.  IPython has a pretty extensive list 
of command-line flags, some which overlap with Python ones: historically 
ipython was meant to be a replacement for the interactive mode ONLY, I didn't 
really have in mind it being used to run files almost as a 'python on top of 
python', so I made no attempt to separate the two set of command-line flags, 
and honestly, I hadn't really given the issue too much thought.

Now, however, I do see value in this, and even I often like to run entire 
programs with ipython sitting in, just to benefit from the nicer/better 
tracebacks and the ability to pop in at the end for interactive work.  In 
order to cleanly pass flags such as -Q which affect the python VM globally, it 
would be necessary to control the start of the python process itself, and the 
shell script approach you suggest seems the cleanest.  My shell scripting 
abilities are very primitive, and I'm behind on a number of ipython-related 
things, but I should be able to find something on the net to steal 
argument-handling code from.  Since all that's needed is one more flag, say 
'pyopt', it shouldn't be to hard to write.  Basically, the call would be:

ipython -pyopt='-Q new --foo --bar' --ipython-options-follow

The shell script would only have to call python with the value of pyopt, and 
pass the rest of the arguments to ipython itself:

python $pyopt ipython.py $rest_of_options

For a good shell-scrpiter, this should be 15 minutes' worth of work.  For me, 
it would take a while.

My only concern is portability: the bash approach will not work under plain 
win32 (though it may under cygwin), and I do try to keep ipython mostly 
feature-complete across platforms.



More information about the IPython-user mailing list