3

So, I'm making a python cheat sheet for myself, and when I started covering comparison operators, I noticed these two:

a = 1
b = 2

if a != b:
 print("Dunno")

if a <> b:
 print("Dunno")

I'm using python 2.7 and was curious if there's a difference between the two operators?

user2528030
  • 51
  • 1
  • 3
  • 1
    This is a dupe, but Google and Stack Overflow search suck at finding these operators. – Martijn Pieters Jul 01 '13 at 17:12
  • I am no expert in Python but in SQL they are nearly identical. <> is considered language specific to MySQL as it is not standardized accross the board. I would just use "!=" – ProfileTwist Jul 01 '13 at 17:12
  • Yeah, lots of information on the operators, but I couldn't find the difference between them; which makes sense, seeing as there isn't one :P Thanks guys edit: Save for currency – user2528030 Jul 01 '13 at 17:18
  • See [this question on is-there-a-not-equal-operator-in-python](http://stackoverflow.com/questions/11060506/is-there-a-not-equal-operator-in-python) – user1549804 Jul 01 '13 at 17:22

2 Answers2

6

As described in the documentation, they are the same. <> is deprecated and was removed in Python 3, so you should use !=.

BrenBarn
  • 228,001
  • 34
  • 392
  • 371
2

<> is deprecated. Other than that, no.

Ignacio Vazquez-Abrams
  • 740,318
  • 145
  • 1,296
  • 1,325