Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Python check object reference equality

Use the is operator. See simple linked list example below

>> class Node:
...   def __init__(self,val):
...     self.val = val
...     self.next = None
... 
>>> a = Node(5)
>>> a.next = Node(6)
>>> b = a.next
>>> b is a.next
True