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


Groups > comp.lang.python > #28094

Re: Are the property Function really useful?

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeder2.ecngs.de!ecngs!feeder.ecngs.de!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'essentially': 0.04; 'attribute': 0.05; 'attributes': 0.07; 'computed': 0.07; '"a"': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Function': 0.09; ';-)': 0.11; 'language': 0.14; 'cases': 0.15; 'slightly': 0.15; '"b"': 0.16; '"d"': 0.16; '(rather': 0.16; 'attributes.': 0.16; 'attributes:': 0.16; 'function?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'fine,': 0.22; 'implicit': 0.22; 'programming': 0.23; 'feature': 0.24; 'allows': 0.25; 'header:User-Agent:1': 0.26; 'i.e.': 0.27; 'see,': 0.27; 'fixed': 0.28; 'header:X-Complaints- To:1': 0.28; 'thus,': 0.29; 'writes:': 0.29; 'class': 0.29; 'function': 0.30; 'implement': 0.32; 'to:addr:python-list': 0.33; 'subject:?': 0.35; 'there': 0.35; 'received:org': 0.36; 'really': 0.36; 'but': 0.36; 'charset:us-ascii': 0.36; 'subject:: ': 0.38; 'instead': 0.39; 'to:addr:python.org': 0.39; 'application': 0.40; 'where': 0.40; 'header:Received:5': 0.40; 'skip:u 10': 0.60; 'received:217': 0.68; 'valued': 0.78; 'differently:': 0.84; 'invested': 0.84; 'subject:Are': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dieter Maurer <dieter@handshake.de>
Subject Re: Are the property Function really useful?
Date Thu, 30 Aug 2012 09:36:46 +0200
References <6ab76fcc34adc04a8b113b77c1e85606@pc-20120706ouob>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e09039.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:/OjbkwmC+HbAdKCNNEtBHXr3v7I=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.3959.1346312228.4697.python-list@python.org> (permalink)
Lines 31
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1346312228 news.xs4all.nl 6864 [2001:888:2000:d::a6]:54247
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:28094

Show key headers only | View raw


<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 comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web