Definition of "property"
dn
PythonList at DancesWithMice.info
Sun May 30 17:19:00 EDT 2021
On 31/05/2021 04.57, Irv Kalb wrote:
> I am doing some writing (for an upcoming book on OOP), and I'm a little stuck.
>
> 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. The editor is asking for a definition of property. I've looked at many articles on line and a number of books, and I haven't found an appropriate one yet.
>
> I have written some good examples of how it works, but I agree that a definition up front would be helpful. I have tried a number of times, but my attempts to define it have not been clear. Perhaps the best I've found so far is from the Python documentation:
>
> A property object has getter, setter, and deleter methods usable as decorators that create a copy of the property with the corresponding accessor function set to the decorated function.
>
> But I'm hoping that someone here can give me a more concise (one or two sentence) definition of the word "property".
>
> (I would like to avoid going through the whole derivation with the property function, as that would distract from the points that I am trying to make.)
+1
Everything in Python is an object. Objects can perform an
almost-unlimited range of services, fulfilling a wide variety of
purposes. A property constrains the object to more focussed functionality
...
eg an integer which may not hold a negative value, a string which may
not be empty...
--
Regards,
=dn
More information about the Python-list
mailing list