Division considered un-Pythonic (Re: Case-sensitivity: why -- or why not? (was Re: Damnation!))
Konrad Hinsen
hinsen at cnrs-orleans.fr
Tue May 30 10:41:00 EDT 2000
Travis Oliphant <olipt at mayo.edu> writes:
> > Currently, Python provides no way for you to directly specify
> > which one you want -- instead, it uses a heuristic based on the
> > run-time types of the arguments. This clearly violates the principle
> > of not trying to guess what the programmer meant. Therefore, it
> > is un-Pythonic. QED.
> >
>
> Thank you for this clear explanation. I agree with this statement. I
> have been bit several times by this problem of being able to specify which
> kind of division I want and having it depend on input types.
Me too. Moreover, the only way to ensure that no integer division will
take place is to write (1.*a)/b or (0.+a)/b, which looks rather weird
unless you know the trick. float(a)/b is more obvious but will yield a
very wrong result if a happens to be complex.
--
-------------------------------------------------------------------------------
Konrad Hinsen | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.55.69
Rue Charles Sadron | Fax: +33-2.38.63.15.17
45071 Orleans Cedex 2 | Deutsch/Esperanto/English/
France | Nederlands/Francais
-------------------------------------------------------------------------------
More information about the Python-list
mailing list