Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.009 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'attributes': 0.09; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'subject:method': 0.09; '~ethan~': 0.09; 'def': 0.12; '@property': 0.16; 'filename:fname piece:signature': 0.16; 'pythonic': 0.16; 'wrote:': 0.18; 'header:User-Agent:1': 0.23; 'define': 0.26; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'properties': 0.29; 'object.': 0.31; 'knows': 0.35; 'method': 0.36; 'charset:us-ascii': 0.36; 'subject:?': 0.36; 'should': 0.36; 'throughout': 0.37; 'so,': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'received:173': 0.61; 'such': 0.63; 'life': 0.66; 'to,': 0.72; 'subject:skip:w 20': 0.91 Date: Thu, 11 Dec 2014 10:34:58 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: is_ as method or property? References: In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="iCU3n4WlEBL5JlTnpE8A9akxhwI170Tdo" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 60 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418322914 news.xs4all.nl 2962 [2001:888:2000:d::a6]:47059 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82371 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --iCU3n4WlEBL5JlTnpE8A9akxhwI170Tdo Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable On 12/11/2014 09:34 AM, Mateusz Loskot wrote: >=20 > def is_(): > pass >=20 > like 'is_even'. >=20 > Should I define it as a classic method >=20 > def is_even(self): > pass >=20 > or as a property >=20 > @property > def is_even(self): > pass >=20 > 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 thr= oughout the life of the object. -- ~Ethan~ --iCU3n4WlEBL5JlTnpE8A9akxhwI170Tdo Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) iQIcBAEBAgAGBQJUiePVAAoJENZ7D1rrH75NSBQP/RWegCi3uRMljg2jYXR9fWTH fU1tYDmZ1HHvz6I3B2ErdjUbrzXJAGhZdT7wshmT5iikr/5p9mWNgfA/ejbEXYKC BcpJD9wZS+3OJPlnNxUNCDlgtq7WyJQBLzvg0ExkOETdaFEkxdXtpqx+yOKT8QWA Kptmx8CtBw+Ycv32FF+wDjmAUZthVzAD+A6ucE9N+vOwhRp6UteU2GaeOc7B4dIg f3VdBSNKT993HtHEEW/dhYTWhgFI0t+YUyJkM9PIdyrG+Zr41fnw0rTkCrH4d8HX HSG0T6jkoBpknccfJsRtDG64cVZSNK3iEFfKUYtwcRst7K/+Z5tak/jtH+OkaYvY vLmVN56tdMbz4bRKY6eA3akaI6bTr7q4qjcRaUpPZQAEpRcNyXyd6+W4HiUL+pJC nSdqxLLH9uxuGGPntaYzUEH0qiTAGBhMPbnFxTr4fYbSqUDHoPfOyWP6UMMIKR2i WuGNWpm88jqZGOK0NfNZX/NiKXee+e/O6BgpW7qLWyaxZ9D8J+YdS58P0af1EnDJ mTV+HNowBVH8qpPA4fmyUGWX7azBQVslNSBNcOxlVTNjM9fxG0TnxouLAAEBhF42 UrY7YTCbfRAq7rnPaMA+FeZzYS8S+xLaa2Qqflpg4XtsRp40ImSq7/bm6av5U2sN z1JaFMwkCaGMUgt9EUoc =3yCV -----END PGP SIGNATURE----- --iCU3n4WlEBL5JlTnpE8A9akxhwI170Tdo--