An oddity in list comparison and element assignment

michael.f.ellis at gmail.com michael.f.ellis at gmail.com
Thu Jun 1 22:31:01 CEST 2006


Considering the number of new programmers who get bit by automatic
coercion, I wish Dennis Ritchie had made some different choices when he
designed C.  But then I doubt he ever dreamed it would become so wildly
successful.

Being a curmudgeon purist I'd actually prefer it if Python raised a
TypeError on float vs integer comparisons.

Cheers,
Mike

Kent Johnson wrote:
> michael.f.ellis at gmail.com wrote:
> > Hi Alex,
> > With all due respect to your well-deserved standing in the Python
> > community, I'm not convinced that equality shouldn't imply invariance
> > under identical operations.
> >
> > Perhaps the most fundamental notion is mathematics is that the left and
> > right sides of an equation remain identical after any operation applied
> > to both sides.  Our experience of the physical world is similar.  If I
> > make identical modifications to the engines of two identical
> > automobiles, I expect the difference in performance to be identical.
> > If my expectation is met, I would assert that either the two vehicles
> > were not identical to begin with or that my modifications were not
> > performed identically.
>
> But programming is not mathematics and assignment is not an equation.
> How about this:
>
> In [1]: a=3.0
>
> In [2]: b=3
>
> In [3]: a==b
> Out[3]: True
> 
> In [4]: a/2 == b/2
> Out[4]: False
> 
> Kent




More information about the Python-list mailing list