Are the property Function really useful?

Dieter Maurer dieter at
Thu Aug 30 09:36:46 CEST 2012

<levinie001 at> writes:

> Are the property Function really useful?

Someone invested time to implement/document/test it.
Thus, there are people who have use cases for it...

> Where can i use the property function?

You can use it when you have parameterless methods
which you want to access as if they were simple attributes:
i.e. "obj.m" instead of "obj.m()".
To phrase is slightly differently: the "property" function
allows you to implement "computed" (rather than "stored") attributes.

You may find this feature uninteresting: fine, do not use it...

However, there are cases where it is helpful, e.g.:

  You have a base class "B" with an attribute "a".
  Now, you want to derive a class "D" from "B" where "a" is
  not fixed but must be computed from other attributes.

The "Eiffel" programming language even stipulates that
attributes and parameterless methods are essentially the same
and application of the "property" function is implicit in "Eiffel"
for parameterless methods: to hide implementation details.

As you see, "property" can be highly valued ;-)

More information about the Python-list mailing list