Language change and code breaks

Konrad Hinsen hinsen at cnrs-orleans.fr
Thu Jul 12 05:00:38 EDT 2001


David Bolen <db3l at fitlinxx.com> writes:

> Of course, if a was complex then we wouldn't be worried about a/b
> truncating anything either.  But definitely something to keep in mind
> if working on code that might receive either complex or integer
> parameters.

Whenever you know the type of your objects there is no problem. But
often you want to write a mathematical expression which accepts any
reasonable type, even Python classes with a number interface. An
explicit cast to float() is very undesirable in such situations, and
a hack such as (a+0.)/b is not obvious to the uninitiated.

A special operator, // or whatever, with the meaning of "the best
approximation to standard artihmetic division that is available" is
the best way to express this, in my opinion. Perhaps some number-like
classes could even reimplement it in some clever way.

Konrad.
-- 
-------------------------------------------------------------------------------
Konrad Hinsen                            | E-Mail: hinsen at cnrs-orleans.fr
Centre de Biophysique Moleculaire (CNRS) | Tel.: +33-2.38.25.56.24
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