I just don't get it

Stephen Horne steve at ninereeds.fsnet.co.uk
Fri Feb 27 19:33:41 EST 2004


On Sat, 28 Feb 2004 00:14:29 +0000, Stephen Horne
<steve at ninereeds.fsnet.co.uk> wrote:

>If Python started trying to guess your intentions, and assumed that
>you really meant to compare the values, a whole load of quite basic
>things wouldn't work.

Just thought I'd chuck in a different example of what could happen if
Python started second guessing intentions.

  (1,) == 1 .......... the numbers are both 1, after all

  (1,) == () ......... maybe you're just checking they're both
                       tuples, after all?

But then for both those to be true, you also get...

  1 == () ............ because 1 == (1,) == ()
  2 == () ............ because 2 == (2,) == () by the same logic

  1 == 2 ............. because 1 == () == 2


In short, you either have to live with inconsistencies in ordering
relationships that break standard algorithms and lead to all kinds of
unexpected problems in any program over about 100 lines of code, or
you have the ultimate egalitarian society of objects where every
object is equal to every other object, irrespective of value or
anything else.

Neither seems attractive to me.


-- 
Steve Horne

steve at ninereeds dot fsnet dot co dot uk



More information about the Python-list mailing list