Python3k extended grammar

Greg Ewing greg at cosc.canterbury.ac.nz
Sun May 21 23:44:10 EDT 2000


Dmitry Rozmanov wrote:
> 
> operation(int, int) _must_ give int, NOT float

You're thinking about it the wrong way. It's
operation(float,float) -> float. It just happens
that if you give it two ints, they get promoted
to floats by the normal coercion rules before
the operation.

It's just the same as sqrt(int) -> float, etc.
I've never heard anyone complain that
math.sqrt(5) doesn't return 2, for instance...

-- 
Greg Ewing, Computer Science Dept,
+--------------------------------------+
University of Canterbury,	   | A citizen of NewZealandCorp, a	  |
Christchurch, New Zealand	   | wholly-owned subsidiary of USA Inc.  |
greg at cosc.canterbury.ac.nz	   +--------------------------------------+



More information about the Python-list mailing list