August 2018
Intermediate to advanced
332 pages
9h 12m
English
The first parameter, instance, refers to the object from which the descriptor is being called. In our first example, this would mean the client object.
The owner parameter is a reference to the class of that object, which following our example (from the previous class diagram in The machinery behind descriptors section) would be ClientClass.
From the previous paragraph we conclude that the parameter named instance in the signature of __get__ is the object over which the descriptor is taking action, and owner is the class of instance. The avid reader might be wondering why is the signature define like this, after all the class can be taken from instance directly (owner = instance.__class__). There is an edge ...
Read now
Unlock full access