def __eq__(self, other):
if isinstance(other, TokenWithPosition):<EOL><INDENT>return self.text == other.text<EOL><DEDENT>else:<EOL><INDENT>return self.text == other<EOL><DEDENT>
>>> TokenWithPosition('asdf', 0) == TokenWithPosition('asdf', 2)
True
>>> TokenWithPosition('asdf', 0) == TokenWithPosition('asd', 0)
False