proposed language change to int/int==float (was: PEP0238 lament)

Terry Reedy tjreedy at home.com
Thu Jul 26 23:35:16 EDT 2001


> [Guido]
> Well, they have the same *mathemtical* value, and Python does its
> darndest to treat them as equal everywhere.  For example, a dict
with
> int keys can be indexed with corresponding float or complex values.
> Exceptions are operations that intrinsically require ints, e.g. list
> indexing.  (This would change under a unified numeric system though,
I
> expect, unless inexact numbers are excluded from being used as
> sequence indices.)

If I write def(seq, n, k): return seq[3*n//k] and a call receives
n=20.0 instead of 20, it would accord with the polymorphic rationale
for new / and // to go ahead and return the item intended.  Or perhaps
floored numbers should be marked as exact (if the marking is
independent of type).

Terry






More information about the Python-list mailing list