Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #82371
| Date | 2014-12-11 10:34 -0800 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: is_<whatever_you_are_testing_for> as method or property? |
| References | <CABUeae-rNeN_dGgkgauNr+-qChXvkgenBmgLbFioe+JDqiT+Hg@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.16863.1418322914.18130.python-list@python.org> (permalink) |
[Multipart message — attachments visible in raw view] - view raw
On 12/11/2014 09:34 AM, Mateusz Loskot wrote: > > def is_<whatever_you_are_testing_for>(): > pass > > like 'is_even'. > > Should I define it as a classic method > > def is_even(self): > pass > > or as a property > > @property > def is_even(self): > pass > > So, a classic method or a property, which one is the Pythonic 3 way for > such member predicates? Generally, attributes (and properties look like attributes) are for items that the object already knows the answer to, and methods are for things that need to be calculated, and may change throughout the life of the object. -- ~Ethan~
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: is_<whatever_you_are_testing_for> as method or property? Ethan Furman <ethan@stoneleaf.us> - 2014-12-11 10:34 -0800
csiph-web