deja/vu

Terry Reedy tjreedy at home.com
Tue Jul 31 20:29:09 EDT 2001


Here's a deja vu article for the 100,000 post celebration [8<)

In a 40-article comp.lang.python thread accessable as
http://groups.google.com/groups?hl=en&safe=off&th=1d9d3c24ba2f933d&sta
rt=10
a pharmacist reported his conversion of life-critical dose-calculation
programs from Basic to Python.

In messages 3&4, Tim Peters and Fredrik Lundh warned him about  1/2=0.
Selected quotes from the discussion that followed:

Greg Ewing(15):
It's a nuisance in C, but at least there you know whether you're
dealing with ints of
floats. In a dynamically typed language, where you don't know when you
write the code whether you'll get an int or a float, it's lunacy!

Tim Peters (10):
... if "/" floated ints and *they* had to type "//" to get integer
division.
Which may or may not be what Guido would like to do for Python2.

Guido van Rossum(12):
For the record, this seems a reasonable solution if we can overcome
the breakage of all the code that relies on truncating integer
division.
Perhaps the // notation should be introduced sooner to
provide a migration path?  [Would that he had - TJR]
(It would be easier if it were a function, e.g. div(x, y).)

[Tim Peters(16) in response to that line:
less attractive because the translation program would have a harder
job
in several respects.  By-hand conversions would also be harder.]

GvR continuing:
What would 3.0//2.0 (or div(3.0, 2.0)) mean?  Aha, there's a
precedent: use divmod(3.0, 2.0)[0], which yields 1.0 today.

Michael McLay(13):
Any guesses on how much code would be broken by making the change?
...
How loudly would people scream if Guido made such a drastic change in
the 1.6 release?

Andrew Kuchling(14):
Very, very loudly.  ... it's better held off until a x.0 release.

...

Terry J. Reedy






More information about the Python-list mailing list