Comparisons in Python: the difference between “is” and “==”

Adrienne Domingus
3 min readJan 19, 2020

Comparing one thing to another is constant in programming. But Python has two ways to do this: == and is. So what’s the difference, anyway?

Let’s give ourselves a class to work with as we see how this all works. A cat, obviously.

class Cat():
def __init__(self, name): = name
def __eq__(self, other):
return ==

You’ll notice we’ve defined an __eq__ method on our Cat class: this lets us give a…