Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #28094 > unrolled thread
| Started by | Dieter Maurer <dieter@handshake.de> |
|---|---|
| First post | 2012-08-30 09:36 +0200 |
| Last post | 2012-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.
Re: Are the property Function really useful? Dieter Maurer <dieter@handshake.de> - 2012-08-30 09:36 +0200
| From | Dieter Maurer <dieter@handshake.de> |
|---|---|
| Date | 2012-08-30 09:36 +0200 |
| Subject | Re: 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 ;-)
Back to top | Article view | comp.lang.python
csiph-web