The Artima Developer Community
Sponsored Link

Software Jam Sessions
Requiem for an operator
by Barry Warsaw
August 24, 2006
Summary
Guido kills <> in Python 3000. I am sad.

Advertisement

I heard the news today, oh boy

This came in my email today:

Author: guido.van.rossum
Date: Thu Aug 24 05:53:23 2006
New Revision: 51538

Killed the <> operator.  You must now use !=.

I knew this day would come and yet I'm still sad. Having known Guido as long as I have, I also know that the likelihood he'll change his mind is about the same as Tim Peters eating anything other than Kung Pao chicken at an outing to China King restaurant. Still, I have a strong attachment to this operator so I'm returning to my blog in final remembrance and to once again explain why I like <> so much more than !=.

The argument for <>

There are several reasons why I think <> is the better spelling for inequality. First, it's symmetrical and thus feels more closely related to its opposite, == for equality. Split either symbol vertically down the center and the two sides are mirrors of each other. The symmetry appeals to my eye.

Second, <> stands out much better in code that already has == and = strewn about it. Maybe it's just me, but != is less visually distinct and my eye has a much harder time picking this out. It always has for C and Java, will so in Python code as well.

Third and most importantly, <> is much easier to type (on a US keyboard at least). Think of the chording you have to do on a keyboard to type the two inequality operators. For <>, you hold the left shift down with your left pinkie, and then hit comma and period with the second and third fingers of your right hand. Quick and easy. With != I have to go through these movements:

  • Hold right shift with my right pinkie and stretch my left ring finger all the way up to the 1 key
  • (or hold left shift with my pinkie while doing the same left ring finger stretch)
  • Let up on the shift key and stretch my right ring finger up to the = key at the opposite side of the keyboard

There's no question that != is more awkward and slower to type. For me it's actually more painful too.

The argument for !=

Let's examine some of the arguments I've heard in favor of != instead of <>.

First, TOOWTDI. This Python guiding principle stands for "There's Only One Way To Do It", and it's a principle that should be honored in this case too. Note however, this doesn't really argue in favor of either symbol -- it could just as appropriately be invoked for keeping <> and ditching !=.

Another argument I've heard is that ! is a common character meaning "not" so != clearly means "not equal", while <> means "less than and greater than" and that's nonsensical. Well, != does not mean "not equal", it means "not an assignment" which is equally <wink> nonsensical. To literally mean "not equal" in Python, you'd have to write !== and no one's suggesting that!

Third, I've heard that people coming from Java and C will be more comfortable with != than <> because that's what those languages use. This doesn't hold much water for me because any programmer worth their salt will understand that they have to make adjustments when they switch languages. How often do you type semicolons at the end of your Python statements? How often do you type colons at the end of your C conditionals? Yeah, me neither. Switching to <> when writing Python would actually be a good thing because it re-enforces the differences between Python and C/Java.

A Farewell

Ultimately I believe this change was made because Guido simply likes != better than <> and thus it comes down to a religious argument. Since he's the BDFL and Python is his language, he gets to make these decisions. I don't have to like it, but I'll learn to live with it... eventually.

In the meantime, here's my Ode to Inequality:

One's not assignment but looks like such
One's less and more but not by much
One's within reach, an easy touch
One looks like C, a useful crutch

My fingers ache and stretch and pull
To type the Py three inequal
The end is near for symbol's duel
I mourn the loss of diamond jewel

The BDFL's made his choice
To heed the call of Java's voice
Some will cry and some rejoice
And sed will lend a heavy hoist

I'll linger then on Py two dot
So I can have my equal not
The angle brackets killed and caught
In Guido's evil bang key plot

So join me now in sweet revolt
To Ruby, Perl, or Tcl bolt
Naw, I'm just kidding truth be told
But wouldn't that be quite a jolt?

I'm just an old crumudgeon, moody
Who thinks bang equals looks like doody
So call me nuts or call me snooty
I guess I'll eat my TOOWTDI fruity

Talk Back!

Have an opinion? Readers have already posted 13 comments about this weblog entry. Why not add yours?

RSS Feed

If you'd like to be notified whenever Barry Warsaw adds a new entry to his weblog, subscribe to his RSS feed.

About the Blogger

Barry Warsaw has been developing software and playing music for more than 25 years. Since 1995 he has worked in Guido van Rossum's Pythonlabs team. He has been the lead developer of the JPython system, and is now the lead developer of GNU Mailman, a mailing list management system written primarily in Python. He's also a semi-professional musician. Python and the bass are his main axes. Music and software are both at their best when enjoyed, participated in, and shared by their enthusiastic fans and creators.

This weblog entry is Copyright © 2006 Barry Warsaw. All rights reserved.

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2014 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us