Numeric don't compare arrays correctly

Tim Hochberg tim.hochberg at ieee.org
Fri Jun 6 21:27:49 EDT 2003


Alexander Schmolck wrote:
> "Mike C. Fletcher" <mcfletch at rogers.com> writes:
>>Alexander Schmolck wrote:
>>...
>>
>>
>>>``3 < 1 < 4`` (False in python, True in most other languages where it isn't a
>>>syntax error)
>>>
> 
> 
>>OMG! That's horrific! It actually took me 3 or 4 seconds to even come up
>>with a rationale for why it would be considered true when it so obviously is
>>trying to say something false.
> 
> 
> Well, it is only obvious because you (and I) are already used to a rather
> hackish notation.
[SNIP]
>>Every once in a while I thank Guido for God's common sense (or vice versa).
> 
> 
> I tend to agree, but in this case I'm not so sure. After all pythons
> conformance with the expected "common sense" behavior breaks down nastily for
> rich comparisons.

An ill considered thought: I wonder if it would be feasible to change 
the definition of "a < b < c" from:
   (a < b) and (b < c)
to:
   (a < b) & (b < c)

Since "x and y" and "x & y" are equivalent when x, y are in (0,1), this 
should work for pre-rich comparison classes and it would work correctly 
for Numeric's rich compares.

Unfortunately, I'm sure someone's (ab)using rich compares in some way 
different from Numeric that would fail under this model.

-tim





More information about the Python-list mailing list