Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!))

Huaiyu Zhu hzhu at rocket.knowledgetrack.com
Tue May 30 14:15:53 EDT 2000


On 30 May 2000 11:04:50 GMT, Martijn Faassen <m.faassen at vet.uu.nl> wrote:
>Greg Ewing <greg at cosc.canterbury.ac.nz> wrote:
>[snip]
>> I assume that no-one would disagree with the following statements:
>
>> 1. Integer division and real (or rational, if you prefer) division
>>    are different operations.
>
>Question: why does nobody complain about the overloading of the '+' 
>operator? After all, it works on both strings and numbers; and presumably
>your code will fall apart at unsuspected points as well if you assume it
>only deals with numbers. :)

Two points worth considering:
1. The int to float conversion is often automatic: sqrt(2)
2. a/b produces different results based on type without warning.

My experience is that any time a computer language tries to use "smart
guess" to resolve ambiguity it generally creates more trouble than it saves,
even if it guesses right 95% of the time.



More information about the Python-list mailing list