In the first case, the Test class has a handle for your class A, since it defines the __get__ and __set__ .
If you use any class with __get__ , __set__ methods, as an attribute of your class, it acts as a descriptor for your class, and not as an attribute .
So, when you assign something to this variable, the descriptor's __set__ method is __set__ , and when you try to access it, the descriptor's __get__ method is __get__ . Descriptors simply provide access to class attributes through getters and setters
So, when you do a = Test() in your class A, the __get__ descriptor method is __get__ , and it is set to 42 .
While in the second case, you create a class Test in the same way as every other class. So aa represents a reference to an instance of the Test class.
source share