How can I use cmp(a,b) with Python3? I was told that using the cmp function can be very useful in code-golf. But unfortunately, Python 3 doesn't have a cmp function.

So what's the shortest equivalent of cmp that works in python 3?
Python 3 does not have cmp. For golfing, you can do

11 chars

(a&gt;b)-(a&lt;b)


which loses 3 chars over cmp(a,b).

Amusingly, this is also an "official" workaround. The What's New in Python 3 page says "(If you really need the cmp() functionality, you could use the expression (a &gt; b) - (a &lt; b) as the equivalent for cmp(a, b).)"