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


Groups > comp.lang.python > #82438

Re: is_<whatever_you_are_testing_for> as method or property?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.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.020
X-Spam-Evidence '*H*': 0.96; '*S*': 0.00; 'attribute': 0.07; 'style.': 0.09; 'subject:method': 0.09; 'cc:addr:python-list': 0.11; 'attribute,': 0.16; 'boolean': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'instance,': 0.24; 'cc:2**0': 0.24; "i've": 0.25; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'dec': 0.30; 'message-id:@mail.gmail.com': 0.30; 'class': 0.32; 'cases': 0.33; 'fri,': 0.33; 'something': 0.35; 'received:google.com': 0.35; 'subject:?': 0.36; 'pm,': 0.38; '12,': 0.39; 'more': 0.64; 'obvious': 0.74; 'subject:skip:w 20': 0.91; 'to:none': 0.92
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; bh=f7ESjna63xFmbSN+UehXZUWq6m7HlaTYIAwURIvjTmw=; b=egYxs/hkncePF1kf9OQOPcqpqUq4IqZm3w34ehDFP7hDHqdhwkEeq41u/8zYudxNBe rStU+6pYlA+YPuc3dz3VGyNRfYPcHgy0xEbfM4+YbU6NhYYc8PcNxpHCWZgExR87ckIK N0HVXPdsEU+fTHAOU1w0MN8dKIUD/hjLgtaNyTfMUu2WIS5w5QuPcUuJCGs8DOme78AA uw38Wv4CJB+1iMl729t1qJEZKeApx+NvUayxAf38+Ta7v6faGJ735uMFj7jkJQUov5a4 u9toaMSC30PjoFnD6CxjbqJ+1avkoAhMMWAmsWqNh9HUs/cqRFOd1HOOM2cNxMa18/0Q BrTA==
MIME-Version 1.0
X-Received by 10.50.33.51 with SMTP id o19mr1988936igi.34.1418383602272; Fri, 12 Dec 2014 03:26:42 -0800 (PST)
In-Reply-To <CABUeae9ukrw8iYan+iFj_6-V7LT0MVm+heVDWv7zEkqEAMim+g@mail.gmail.com>
References <CABUeae-rNeN_dGgkgauNr+-qChXvkgenBmgLbFioe+JDqiT+Hg@mail.gmail.com> <CAPTjJmojWeyB_bv-6Rjzkno6Cb7NiUKo7rt4Th6fvNPOsGv_jQ@mail.gmail.com> <CABUeae9ukrw8iYan+iFj_6-V7LT0MVm+heVDWv7zEkqEAMim+g@mail.gmail.com>
Date Fri, 12 Dec 2014 22:26:42 +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
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.16904.1418383605.18130.python-list@python.org> (permalink)
Lines 16
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1418383605 news.xs4all.nl 2846 [2001:888:2000:d::a6]:33454
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:82438

Show key headers only | View raw


On Fri, Dec 12, 2014 at 10:21 PM, Mateusz Loskot <mateusz@loskot.net> wrote:
> I've got several cases which are not obvious to me.
> For instance, class Foo has a boolean attribute, read-write,
> which I see a couple of realisations for possible:
>

0) Attribute only.

class Foo:
    pass

Foo().default = True

Unless you need something more than this, go with this style. Much simpler.

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 22:26 +1100

csiph-web