Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #28094 > unrolled thread

Re: Are the property Function really useful?

Started byDieter Maurer <dieter@handshake.de>
First post2012-08-30 09:36 +0200
Last post2012-08-30 09:36 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Are the property Function really useful? Dieter Maurer <dieter@handshake.de> - 2012-08-30 09:36 +0200

#28094 — Re: Are the property Function really useful?

FromDieter Maurer <dieter@handshake.de>
Date2012-08-30 09:36 +0200
SubjectRe: Are the property Function really useful?
Message-ID<mailman.3959.1346312228.4697.python-list@python.org>
<levinie001@gmail.com> 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 ;-)

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web