Class or instance - who owns that name?
Let me give a piece of code first. class C: x = 5; def f(self): self.x += 1; c = C() c.f() print(c.x, C.x) My understanding says that an instance will look up a name within itself, and if there's no such name, it will search the class. So x doesn't really belong to c, it belongs to C - it's a class member. If the function said x = 6, I would understand the result: c gets its own x and the class's x will never be looked up. However, x += 1 means (or should mean) that an already existing value is incremented. In a regular situation, if there is no such name in the scope, this would throw an error. Since c looks up C's x, I would understand if the class member would be altered. Instead, an instance x is CREATED! The output: 6 5 What's going on here?