Skip to main content
Journey Uncommon Logo
JourneyUncommon
hardPythondata model dunder dispatchSingle-choice MCQ

What does a += b do here, and what does the identity check reveal about in-place operator dispatch when __iadd__ is absent?

class A: def __init__(self, v): self.v = v def __add__(self, o): return A(self.v + o.v) a = A(1) before = id(a) a += A(2) print(id(a) != before, a.v)