def __eq__(self, o): if isinstance(o, AST): return self.type == o.type and UserList.__eq__(self, o) else: # Don't forbid other types since we may try to compare AST with # Tokens. return self.type == o