Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.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.012 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'example:': 0.03; 'url:pipermail': 0.05; 'method,': 0.09; 'subject:method': 0.09; 'python': 0.11; 'def': 0.12; '*naming': 0.16; '@property': 0.16; 'pythonic': 0.16; 'url:2007-june': 0.16; 'looked': 0.18; 'trying': 0.19; 'tests': 0.22; 'aspect': 0.24; 'skip:e 30': 0.24; 'question': 0.24; "i've": 0.25; 'define': 0.26; 'pass': 0.26; 'defined': 0.27; 'function': 0.29; 'specifically': 0.29; '[1]': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; 'class': 0.32; 'url:python': 0.33; 'cases': 0.33; 'received:74.125.82': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'subject:?': 0.36; 'hi,': 0.36; 'similar': 0.36; 'url:org': 0.36; 'should': 0.36; 'so,': 0.37; 'to:addr:python- list': 0.38; 'received:74.125': 0.39; 'to:addr:python.org': 0.39; 'url:mail': 0.40; 'solve': 0.60; 'most': 0.60; 'simply': 0.61; 'such': 0.63; 'places': 0.64; '3.4': 0.84; 'subject:skip:w 20': 0.91 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:from:date:message-id:subject:to :content-type; bh=uGfvNVLAO1qbmS9QuYGbdZ6uHYHVoaiUz4jC/GYajO4=; b=Tn5NiknApVApinlZH6RhBPFo7FADX6PKrHTWPFNWHhfEP9HSZeKC33EksrFFoOdeX2 evwrxKOxVX5EFxZ+kc2O71qIquzm5Njy1yI7pKvxqJjAbBM0K15DyCKv3r3/KPZ8kRsa /FTN3YzWcfJz2dfB3RpLL/dOwNIiUR5YCCATOgBay0DzcZQY5P+CMTUXpa1Gvnp3lP8F p8Tzv5SncB46W50StlmhiZa5FwzuHeeOYDO8UzkxR27lbL8VTq1TWSxxY9Loc/GgnN+j 84Va5Vc4U0dyRqsGHyke+9v8BBtwNRdaaknv4PgqzLKehI+/eZJW5PmqXtTY26CWamUZ Hm0g== X-Gm-Message-State: ALoCoQmJcLeSu67mvkFwnEY1EYeG/AQaRXv/Lb7QdEwlIoaSHhbfxd2Gnra0dM+jkAwGZDu7ySRu X-Received: by 10.180.8.70 with SMTP id p6mr20867wia.72.1418319296055; Thu, 11 Dec 2014 09:34:56 -0800 (PST) MIME-Version: 1.0 X-Originating-IP: [82.110.183.162] From: Mateusz Loskot Date: Thu, 11 Dec 2014 18:34:25 +0100 Subject: is_ as method or property? To: python-list@python.org Content-Type: text/plain; charset=UTF-8 X-Mailman-Approved-At: Thu, 11 Dec 2014 18:55:58 +0100 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: 44 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1418320559 news.xs4all.nl 2922 [2001:888:2000:d::a6]:59343 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:82367 Hi, I have been looking at various places to answer this dilemma: If a class member function simply tests something and returns a b::oolean call it def is_(): 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 The question above is based on similar question I found [1], but that one is specifically about naming. I'm trying to solve the aspect of implementation of such predicate. I've looked into the Python 3.4 libs and most of such functions is realised as a classic method, but in several cases they are defined with @property decorator, for example: email.message.MIMEPart.iis_attachment ipaddress._BaseNetwork.is_multicast ipaddress._BaseNetwork is_reserved and a few more. So, a classic method or a property, which one is the Pythonic 3 way for such member predicates? [1] *Naming Conventions* by Thorsten Kampe https://mail.python.org/pipermail/python-list/2007-June/438156.html Best regards, -- Mateusz Loskot, http://mateusz.loskot.net