[SciPy-dev] -Qnew option breaks scipy

Robert Kern robert.kern at gmail.com
Sun Apr 30 17:19:06 EDT 2006


Eric Nodwell wrote:
> If a command line switch exists, it will be used.

Sure. And those users need to take responsibility for doing weird things, not
library authors.

> According to http://www.python.org/dev/peps/pep-0238, this project:
> http://www.vpython.org, has a need for running everything with -Qnew .
>  I can't say whether they truely need it or not, I only point it out
> as an example of the above axiom.

And they were wrong to do so.

> This is something which will have to be done eventually anyways, since
> some day -Qnew will become the default.  Maybe not in the 2.x series
> as you point out. 

Definitely not in the 2.x series. From the PEP:

"""
    - Classic division will remain the default in the Python 2.x
      series; true division will be standard in Python 3.0.
"""

Python 3.0 is the backwards-compatibility-breaking release. Scipy will have to
go through much larger changes then than division. Python 3.0 does not exist
yet, and it is impossible to write 3.0-compatible code. We'll have to deal with
those changes later. That's the perfect time to deal with the change in division
behavior.

> OK, I admit I'm not submitting a patch myself,
> merely pointing it out in the hope that someone will say, hey I can
> fix that in 5 minutes.  For all I know however a fix would require a
> major rewrite of scipy.

It's not a 5-minute fix.

> I was using -Qnew because I often use python as an interactive
> calculator and I was getting tired of typing "from __future__ import
> division" so I aliased python -Qnew.  Too bad if this is something one
> ought not to do, because it makes the best calculator that I know of. 
> It does no good to put the future statement in a module listed in
> PYTHONSTARTUP, because then, as you point out, the effect is limited
> to that module.

Have you tried it? The file in PYTHONSTARTUP gets exec'ed, not imported.

[~]$ cat $PYTHONSTARTUP
from __future__ import division
try:
    import readline
except ImportError:
    print "Module readline not available."
else:
    import rlcompleter
    readline.parse_and_bind("tab: complete")

[~]$ python
Python 2.4.1 (#2, Mar 31 2005, 00:05:10)
[GCC 3.3 20030304 (Apple Computer, Inc. build 1666)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 3/2
1.5
>>>

-- 
Robert Kern
robert.kern at gmail.com

"I have come to believe that the whole world is an enigma, a harmless enigma
 that is made terrible by our own mad attempt to interpret it as though it had
 an underlying truth."
  -- Umberto Eco




More information about the SciPy-Dev mailing list