On Friday, July 1, 2016 at 7:07:09 AM UTC+5:30, Ian wrote: > First of all, do you understand what descriptors are? This is a fairly > advanced Python concept. For a general tutorial, I would point you to > https://docs.python.org/3/howto/descriptor.html
I understand what descriptors try to accomplish, but that link is pretty scary! :P I found your explanation to be much better. The other tutorials would simply ignore "owner", offer no explanation, and provide complete working programs -- this made me go crazy! > The owner argument is the class that this Celsius instance is a > descriptor of. Normally that is just type(instance); however it is > possible to invoke the __get__ method on the class object itself > rather than on an instance, in which case owner is (still) the class > object but instance is None. This is the golden explanation I will always be thankful for! :) > It's not clear to me what alternative you're proposing. The reason > celsius is declared on the class is because it's a descriptor, and > descriptors implement properties of classes. Setting an instance > attribute to a descriptor won't accomplish anything. The alternative I'm proposing is indeed what you said: Make `celcius` a per-object attribute and set it up in __init__(). Why will it not accomplish the same thing as setting it on a class-level? Please bear with me a little more and explain. :P -- https://mail.python.org/mailman/listinfo/python-list