Adrienne Domingus

Jan 19, 2020

3 min read

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

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…

Senior Software Engineer |

Love podcasts or audiobooks? Learn on the go with our new app.