Definition of "property"

Dan Stromberg drsalists at gmail.com
Sun May 30 19:40:37 EDT 2021


On Sun, May 30, 2021 at 9:57 AM Irv Kalb <Irv at furrypants.com> 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.)
>
> Thanks in advance,
>

I tend to think of properties as dynamic attributes.

And I'm not their biggest fan.  I don't like having a look where a class
and its parent classes are defined to tell if something that looks like an
attribute, really is an attribute.

I understand that exposing an attribute as part of a public API is faster,
and the ability to make them dynamic later keeps you from painting yourself
in a corner, but I'd rather just slow down computation a little than end up
with a little greater maintenance burden.


More information about the Python-list mailing list