Because the body of the class definition statement is evaluated before the creation of the class object.
So indeed, the class doesn't have that attribute, the class doesn't even exist yet. But the class definition statement has been evaluated.
We know that when generating a class in Python2, if there is a metaclass attribute, it will be generated by the metaclass referenced by the attribute. Bug when the class is not generated, it should have no attribute, how does it control the generation of the class?
If __metaclass__ is a class attribute, how does it control the generation of the class?