Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythonIdentity vs equalitySingle-choice MCQ

A class defines __eq__ to return a truthy non-bool (e.g. the list [1]). What happens when an instance is tested with `obj in [obj]`?

class Weird: def __eq__(self, other): return [1] def __hash__(self): return 1 w = Weird() print(w in [w])