[MATRIX-SIG] integer division etc.
Charles G Waldman
cgw@pgt.com
Tue, 20 Jan 98 13:17:27 EST
Paul Dubois wrote:
> Python is a strange language in which the objects are typed but the entities
> are not declared.
That sums it up well.
> For example, you can define your own Integer class in which
> division is always floating point (hint, hint).
Of course, I'm aware of this. But I thought we were talking about how
the literal expression "1/2" should be handled, not an expression like
Integer(1)/Integer(2) or Number(1)/Number(2).
Zane Motteler writes:
> To me, saying that 1/2 ought to be 0.5 makes about as much
> sense as saying "1"+"2" ought to be 3 rather than "12".
>
Clearly, "1" + "2" should come out to "3". ;-)
Actually, I think I'd like to retract my opinions on the integer
division issue. The fact that I sometimes use Python as a teaching
tool was the motivation behind my desire for 1/2=0.5. As a programmer
I understand the current behavior and can live with it, and think it
would be a bad idea to change the established behavior at this point
in Python's life. So, when I teach beginning programming using
Python, I will just explain about "integer division" and explain
contexts in which it is useful.
_______________
MATRIX-SIG - SIG on Matrix Math for Python
send messages to: matrix-sig@python.org
administrivia to: matrix-sig-request@python.org
_______________