Skip to content

Instantly share code, notes, and snippets.

@cjhanks
Last active August 29, 2015 13:56
Show Gist options
  • Save cjhanks/9334104 to your computer and use it in GitHub Desktop.
Save cjhanks/9334104 to your computer and use it in GitHub Desktop.
class Test(object):
def __init__(self):
self.val = None
def __eq__(self, rhs):
return self.val == None
t_0 = Test()
print(t_0 == None) # True
print(None == t_0) # True
print(t_0 is None) # False
print(None is t_0) # False
class Test(object):
def __init__(self, val):
self.val = val
def __eq__(self, rhs):
return self.val == rhs.val
t_0 = Test(0)
t_1 = Test(0)
print(t_0 == t_1)
print(t_0 is t_1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment