Python 3000 deat !? Is true division ever coming ?
Dave Hansen
iddw at hotmail.com
Mon Feb 20 11:47:28 EST 2006
Caution: bunny trail ahead. Feel free to skip this message, as it
contains no useful content whatever...
On Sat, 18 Feb 2006 12:09:02 +1100 in comp.lang.python, Steven
D'Aprano <steve at REMOVETHIScyber.com.au> wrote:
[...]
>
>I've never even used Matlab. But I have a calculator. (Actually I have
>about half a dozen calculators.) In every single one of them, 1/2 gives
>0.5 instead of 0. I'm even capable of doing that calculation in my head.
>So I don't think true division is only in Matlab.
I have three calculators: an HP-48S, and HP-16C, and NeoCal on my
Palm.
On the HP-48S: 1 <Enter> 2 / -> 500.000000000E-3
On the HP-16C: 1 <Enter> 2 / -> 0 h (c)
On NeoCal: 1 <Enter> 2 / -> 500.e-3
Note: the (c) on the 16C indicates the "carry" bit was set, which the
16C does whenever the remainder of a division is nonzero.
Caveats: The result for each calculator depends on its "mode." In
"programmer" mode, each calculator performs a truncating integer
division. The 16C is in programmer mode by default. The 48S is
almost never in programmer mode since I bought the 16C. NeoCal goes
into programmer mode about 25% of the time I use it. It was in
"Statistics" mode when I powered it up just now.
>
>
>> As you pointed out: the "true division" part of "Python3000" might be
>> one of the "scariest" and should therefore be pointed out already in
>> the tutorial !! (It would look quite ugly to newcomers, though)
If you want ugly, consider Pascal. The / operator could not perform
an integer divide, and a compile-time error was generated if you
attempted to use it with integer operands. The integer divide
operator was 'div', e.g. "i = j div k"
>
>The tutorial shouldn't talk about Python3000 at all. What would be the
>point of that? The tutorial is there to teach about the way Python works
>now, not to make guesses and prediction about how it will work some time
>in the indefinite future.
>
>
>> Having said that: I would vote against EVER introducing true division
>> as default - because it will just PISS too many (long time python)
>> people OFF. ;-)
>
>Do you realise that the reason true division was introduced into Python
>was because many long-time Python programmers requested it? So far from
>annoying them, it is a feature that most Python programmers are waiting
>for.
I am a relatively long-time user (since about 1999) of Python, but I
mainly program in C. "True" division probably wouldn't p*ss me off
too bad, and I certainly wouldn't have a problem with new scripts I
wrote. But if it broke old scripts, I wouldn't be extremely happy.
FWIW, ISTM that "true" division would be better implemented by the new
// operator, leaving the behavior of / unchanged. But that's probably
just me.
Regards,
-=Dave
--
Change is inevitable, progress is not.
More information about the Python-list
mailing list