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


Groups > comp.lang.python > #82371 > unrolled thread

Re: is_<whatever_you_are_testing_for> as method or property?

Started byEthan Furman <ethan@stoneleaf.us>
First post2014-12-11 10:34 -0800
Last post2014-12-11 10:34 -0800
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: is_<whatever_you_are_testing_for> as method or property? Ethan Furman <ethan@stoneleaf.us> - 2014-12-11 10:34 -0800

#82371 — Re: is_<whatever_you_are_testing_for> as method or property?

FromEthan Furman <ethan@stoneleaf.us>
Date2014-12-11 10:34 -0800
SubjectRe: is_<whatever_you_are_testing_for> as method or property?
Message-ID<mailman.16863.1418322914.18130.python-list@python.org>

[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~

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web