Language change and code breaks

Nick Perkins nperkins7 at home.com
Wed Jul 11 12:57:38 EDT 2001


"Guido van Rossum" <guido at python.org> wrote in message
news:cplmlvh6dx.fsf at cj20424-a.reston1.va.home.com...
> Very good sumary, Terry.  I'm beginning to get second thoughts about
> integer division -- maybe it's better to leave well enough alone, and
> try to fix areas of the language that could really stand some fixing
> (such as subclassing built-in types).
>
> --Guido van Rossum (home page: http://www.python.org/~guido/)


If changing int/int->int to int/int->float is going to break too much code,
then why not use another operator?

I have seen // suggested as a replacement for int/int->int,
ie. int//int->int,..

but why not leave int/int->int alone,
and use // for int//int->float.

No code breaks, and it is almost as easy for the newbies.

1/2 -> 0
1//2 -> 0.5

That way we still have / = div, % = mod,
and we add // = float-divide.

No need for a 'div' operator or anything like that.


p.s.
Would it be possible to allow operators to be used as first-class functions,
eg:
reduce(+,mylist)

instead of:
import operator
reduce(operator.__add__,mylist)






More information about the Python-list mailing list