On 5/30/21 9:57 AM, Irv Kalb wrote:

> I understand what a "property" is, how it is used and the benefits, but apparently my explanation hasn't made the light bulb go on for my editor.

My answer from Stackoverflow [1]:

> Properties are a special kind of attribute. Basically, when Python encounters 
the following code:
>
>     spam = SomeObject()
>     print(spam.eggs)
>
> it looks up eggs in spam, and then examines eggs to see if it has a __get__, 
__set__, or __delete__
> method — if it does, it's a property. If it is a property, instead of just 
returning the eggs object
> (as it would for any other attribute) it will call the __get__ method (since 
we were doing lookup)
> and return whatever that method returns.

Feel free to use that however you like.  :)

--
~Ethan~


[1] https://stackoverflow.com/a/7377013/208880
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to