Booleans, integer division, backwards compatibility; where is Python going?
David Eppstein
eppstein at ics.uci.edu
Sat Apr 6 13:51:19 EST 2002
In article <slrnaaucmq.3j0.philh at comuno.freeserve.co.uk>,
philh at comuno.freeserve.co.uk (phil hunt) wrote:
> What ambiguities? There is nothing ambiguous about current behavour
> of truth values. Furthermore, there is nothing that, in practise,
> hampers programmers: a programmer can easily learn to use 1 and 0
> for true and false.
>
> The only advantage for the new scheme, as I see it, is it looks
> prettier and is a bit easier for newbies. Ditto for integer
> division.
I think the integer division case is quite different.
With bool, there is little change to actual code behavior, it is more
for the benefit of human readability.
The integer division thing, I think, detracts from readability and may
be harder for newbies, but is necessary to preserve Python's philosophy
of polymorphism: functions should not require their inputs to be of a
specific type, they should behave "the same" as long as they are given
inputs that obey the protocols that the function is expecting. E.g. if
you are iterating over something it usually doesn't matter whether it is
a string, tuple, list, or simple generator. In order to behave
appropriately when dividing by a number that could be 2L or could be
2.0, the function needs to more clearly specify whether integer or
"exact" (meaning approximate floating point unless/until we get
rationals) division was intended.
--
David Eppstein UC Irvine Dept. of Information & Computer Science
eppstein at ics.uci.edu http://www.ics.uci.edu/~eppstein/
More information about the Python-list
mailing list