"!=" is bad form. Re: sorry....never mind

Dave Brueck dbrueck at edgix.com
Fri Mar 9 14:57:27 EST 2001


> [mailto:python-list-admin at python.org]On Behalf Of Peter Schneider-Kamp
> Sent: Friday, March 09, 2001 12:02 PM
> To: Dave Brueck
> Cc: python-list at python.org
> Subject: Re: "!=" is bad form. Re: sorry....never mind

> Dave Brueck wrote:
> >
> > I don't really care if Python keeps <>, but the reason I don't
> like it is
> > because of the example listed above: to me seeing "<>" implies something
> > about the ordering of a and b, namely (a < b) or (a > b), even
> when such an
>
> Well, Python *does* define an ordering of a and b, no matter what
> a and b may be. E.g.:
>
> >>> 1 > (1,2)
> 0
> >>> 1 < (1,2)
> 1
> >>> {"a":1} < u"hello world"
> 1
> >>> {"a":1} > u"hello world"
> 0
>
> So, yes, interpreting "a <> b" as "(a < b) or (a > b)" makes
> perfect sense in Python.

Works? Yes. Makes sense? Definitely not.

My point wasn't about what is or isn't legal in Python but the intuitiveness
of '!=' vs '<>': at first glance the former says to me, "a is not the same
as b" while the latter says "a is less than b or a is greater than b". The
former intuitively makes sense for any "thing" while the latter makes sense
only on objects that can be ordered in some meaningful way.

Put another way, it doesn't really make any difference to me personally, but
'!=' would be easier to explain to a non-programmer than '<>'.

-Dave





More information about the Python-list mailing list