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


Groups > comp.lang.python > #82467

Re: is_<whatever_you_are_testing_for> as method or property?

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> <CAPTjJmpOX2pEgJM7AgOWeOge5+H=QNUd2KH9nKC34PBVJSDUYQ@mail.gmail.com>
From Mateusz Loskot <mateusz@loskot.net>
Date 2014-12-12 22:03 +0100
Subject Re: is_<whatever_you_are_testing_for> as method or property?
Newsgroups comp.lang.python
Message-ID <mailman.16927.1418418244.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 12 December 2014 at 12:26, Chris Angelico <rosuav@gmail.com> wrote:
> 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.


Agreed, in general, but if the question was related to such simple case,
I wouldn't bother asking it.

I mentioned, setting the new value involves more changes to Foo()
instance, so i's not possible to capture it with just an assignment.
Hence, the discussion between property vs method.

Best regards,
-- 
Mateusz  Loskot, http://mateusz.loskot.net

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


Thread

Re: is_<whatever_you_are_testing_for> as method or property? Mateusz Loskot <mateusz@loskot.net> - 2014-12-12 22:03 +0100
  Re: is_<whatever_you_are_testing_for> as method or property? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-12-13 22:24 +1100
    Re: is_<whatever_you_are_testing_for> as method or property? Mateusz Loskot <mateusz@loskot.net> - 2014-12-15 10:56 +0100

csiph-web