Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed2a.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.027 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'attribute': 0.07; 'explicit': 0.07; 'calculating': 0.09; 'method,': 0.09; 'cc:addr :python-list': 0.11; '"get",': 0.16; 'fail,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'retrieving': 0.16; 'seconds.': 0.16; 'subject:Classes': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'cc:addr:python.org': 0.22; '31,': 0.24; 'cc:2**0': 0.24; 'possibly': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'properties': 0.29; 'needed.': 0.30; 'message-id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'fast.': 0.31; 'header,': 0.31; 'steven': 0.31; 'probably': 0.32; 'supposed': 0.32; 'quite': 0.32; 'fri,': 0.33; 'sense': 0.34; 'agree': 0.35; 'except': 0.35; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'should': 0.36; 'audio': 0.38; 'nov': 0.38; 'pm,': 0.38; 'rather': 0.38; 'bad': 0.39; 'ian': 0.60; 'length': 0.61; 'times': 0.62; 'name': 0.63; 'more': 0.64; 'reads': 0.68; 'complex,': 0.84; 'lightweight': 0.84; 'opens': 0.91; 'to:none': 0.92; 'choice.': 0.93 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=JMJ8HN9VkO0fYBjzNF+VagFGbmDsyOJjw+D4/VE9EwQ=; b=iqYYNW5W5lom86uTs0SCm2uFseBZ3oj6WmIYXm0suYY4DmDfI8AsaZNW4E4sVtXIGZ 1f7vYa+4dcpQVChzbFic+EuXAZVNY4SwQoOy6yhNX1EsWl8Fe6eG8aw6pa/5A+r3VvSs o7oklvDrumO4pUrf/oS/snn8NpK5Q73/cwfRJ8VeSOHu2iNAS2h4fNAQT/696exmAvQH Ws0CtS7ZiegPEh/SLT/b6sk2baw5wr7Vqt1V2sDXzpOW6Lo2irq6anQt2jphFow34gRn 2z/j5jhhl6rTzXOEomuwjEwDsenFggDfiSpxPmsKJRHOJYeF6R4NLnnWTankswGAfotW f+iw== MIME-Version: 1.0 X-Received: by 10.50.136.134 with SMTP id qa6mr2065374igb.2.1414823529346; Fri, 31 Oct 2014 23:32:09 -0700 (PDT) In-Reply-To: References: <51755at03r0bidjqh3qf0hhpvjr8756ill@4ax.com> <545350c3$0$23449$426a74cc@news.free.fr> <54543231$0$13000$c3e8da3$5496439d@news.astraweb.com> Date: Sat, 1 Nov 2014 17:32:09 +1100 Subject: Re: Classes From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 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: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1414823532 news.xs4all.nl 2874 [2001:888:2000:d::a6]:41008 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80074 On Sat, Nov 1, 2014 at 5:12 PM, Ian Kelly wrote: > On Fri, Oct 31, 2014 at 7:06 PM, Steven D'Aprano > wrote: >> And there are times when using getters and setters is the right choice. >> Properties should only be used for quite lightweight calculations, because >> attribute access is supposed to be fast. If your calculation is complex, >> time-consuming or might fail, using a property is a bad idea and you should >> use an explicit getter method, possibly with a setter if needed. > > I agree except that in this scenario you should probably use a verb > other than "get", since getters should also be fast. Maybe. "get_track_length()" might be a reasonable method name for something that opens an audio file, reads its header, and returns its length in seconds. It should be a method rather than a property (attribute access should be fast), but "get" makes sense here, as it's not calculating or anything, it's just retrieving information. But yes, if it's a calculation, "calc" would be more common. ChrisA