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


Groups > comp.lang.python > #82387

Re: is_<whatever_you_are_testing_for> as method or property?

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.024
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'attribute': 0.07; 'string': 0.09; 'subject:method': 0.09; 'cc:addr:python-list': 0.11; 'attribute,': 0.16; 'attribute;': 0.16; 'attributes.': 0.16; 'callable': 0.16; 'finney': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'itself,': 0.16; 'lower-case': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'cc:addr:python.org': 0.22; 'creating': 0.23; 'instance,': 0.24; 'logical': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'am,': 0.29; 'properties': 0.29; 'dec': 0.30; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'calculated': 0.31; 'writes:': 0.31; 'file': 0.32; 'fri,': 0.33; 'sense': 0.34; 'there,': 0.34; 'equal': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'method': 0.36; 'subject:?': 0.36; 'should': 0.36; 'detail': 0.37; 'ben': 0.38; 'rather': 0.38; '12,': 0.39; "you're": 0.61; 'skip:\xe2 10': 0.65; 'talking': 0.65; 'here': 0.66; 'between': 0.67; 'owner,': 0.78; 'stat': 0.84; 'subject:skip:w 20': 0.91; 'to:none': 0.92; 'hand,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=CJxwL4RXBCyKFn7ow5BjTJrHNUDBzq40+YSK9HuTTaw=; b=IcNLe25JvY6f640Iev4mBMEq7Y2pGbOGMHs3agpCoBiNtCu2VxPZheCPnzFqcmE5Vj ushrIr7VMEkFHdx3e1EC6B2+kbMz0U2zuu6grEdJgMqjzMM2wzTs+lfYgVZsKPri14yO gz+1+4UNVJdd9BKWRtWY7zO+Lwo7gK8hRpdaToVBSShdcj2SGNyTyBgalIsP/kzQSIKF SKt86AnwMC0KKpgGKVXwn5cb+QctDlHBcD3nwObld0AMPBZSfiRENyeuhuwHxOVvrkeZ FNrrhMp3b9+1ev7/Yplh/eCr+EhjbYVJeipRWD+nc9rc3ymKQzgKGyJ9m0KEzsyxycwe H0XQ==
MIME-Version 1.0
X-Received by 10.50.62.104 with SMTP id x8mr1387910igr.2.1418334568955; Thu, 11 Dec 2014 13:49:28 -0800 (PST)
In-Reply-To <857fxxhnx8.fsf@benfinney.id.au>
References <CABUeae-rNeN_dGgkgauNr+-qChXvkgenBmgLbFioe+JDqiT+Hg@mail.gmail.com> <CAPTjJmojWeyB_bv-6Rjzkno6Cb7NiUKo7rt4Th6fvNPOsGv_jQ@mail.gmail.com> <857fxxhnx8.fsf@benfinney.id.au>
Date Fri, 12 Dec 2014 08:49:28 +1100
Subject Re: is_<whatever_you_are_testing_for> as method or property?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.16874.1418334577.18130.python-list@python.org> (permalink)
Lines 26
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418334577 news.xs4all.nl 2969 [2001:888:2000:d::a6]:32996
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82387

Show key headers only | View raw


On Fri, Dec 12, 2014 at 8:33 AM, Ben Finney <ben+python@benfinney.id.au> wrote:
> Chris Angelico <rosuav@gmail.com> writes:
>
>> A property should be used if what you're creating is "virtually an
>> attribute".
>
> Methods are attributes. Are you distinguishing here between “callable
> attribute” versus “non-callable attribute”?

I'm talking conceptually here. You can, for instance, have a stat
object which has attribute for the file size and owner, and then it
makes equal sense to have an "is_dir" attribute; but that one might be
a property, calculated from the file mode. It makes logical design
sense for it to be an attribute with the value right there, so it
makes design sense for it to be a property. On the other hand, a
string will not normally have, as an attribute, a lower-case version
of itself, so it makes better sense for that to be a callable method
rather than a property.

Yes, properties and methods are attributes. That's a technical detail
that has nothing to do with the design question of "should this be a
property or a method".

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: is_<whatever_you_are_testing_for> as method or property? Chris Angelico <rosuav@gmail.com> - 2014-12-12 08:49 +1100

csiph-web