Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!news.tele.dk!feed118.news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'broken': 0.04; 'from:addr:yahoo.co.uk': 0.04; 'that?': 0.05; '*not*': 0.07; '21,': 0.07; 'everybody,': 0.07; 'lines,': 0.07; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'similar,': 0.09; 'language.': 0.14; 'hint': 0.16; 'ought': 0.16; 'reasonably': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'roy': 0.16; 'two,': 0.16; 'subject:python': 0.16; 'applies': 0.16; ':-)': 0.16; 'language': 0.16; 'wrote:': 0.18; 'pieces': 0.19; '>>>': 0.22; 'header:User- Agent:1': 0.23; '---': 0.24; 'header:X-Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; "doesn't": 0.30; 'especially': 0.30; 'code': 0.31; 'usually': 0.31; "d'aprano": 0.31; 'steven': 0.31; 'fri,': 0.33; 'third': 0.33; 'maybe': 0.34; 'knows': 0.35; 'definition': 0.35; 'but': 0.35; 'there': 0.35; 'in.': 0.36; 'similar': 0.36; 'should': 0.36; 'two': 0.37; 'sometimes': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'rather': 0.38; 'anything': 0.39; 'explain': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'free': 0.61; 'viruses': 0.61; 'here:': 0.62; 'times': 0.62; 'protection': 0.63; 'our': 0.64; 'places': 0.64; 'become': 0.64; 'different': 0.65; 'mar': 0.68; '2-3': 0.68; 'antivirus': 0.68; 'smith': 0.68; 'obvious': 0.74; 'article': 0.77; 'received:2': 0.84; 'absolutely': 0.87 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: running python 2 vs 3 Date: Fri, 21 Mar 2014 09:40:40 +0000 References: <87ob10nbeh.fsf@elektro.pacujo.net> <532B4750.2090006@yahoo.com> <87eh1wpr96.fsf@elektro.pacujo.net> <87a9ckpq7y.fsf@elektro.pacujo.net> <87txasoaqi.fsf@elektro.pacujo.net> <532b8f0d$0$29994$c3e8da3$5496439d@news.astraweb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-198-214.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: X-Antivirus: avast! (VPS 140320-0, 20/03/2014), Outbound message X-Antivirus-Status: Clean 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1395394859 news.xs4all.nl 2977 [2001:888:2000:d::a6]:48993 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:68681 On 21/03/2014 02:18, Chris Angelico wrote: > On Fri, Mar 21, 2014 at 12:06 PM, Roy Smith wrote: >> In article <532b8f0d$0$29994$c3e8da3$5496439d@news.astraweb.com>, >> Steven D'Aprano wrote: >> >>> The rule of three applies here: anything you do in three different places >>> ought to be managed by a function. >> >> I prefer the rule of two :-) > > The way I explain it is: Three is a rule of thumb. Sometimes it's > blatantly obvious at two, and other times you need four or five > similar pieces of code before you can see which part should become the > function. If the code's absolutely identical and reasonably > long/complex, then yes, two's all you need, but how often is that? > Usually it's similar, rather than congruent... err I mean identical. > That's where the third usage comes in. Or if it's maybe 2-3 lines, > used in two places, it doesn't necessarily need to be a function. > Again, a third usage is a strong hint that it should be broken out. > > The rule doesn't say that anything that *isn't* in three places yet > should *not* be broken out. :) > > ChrisA > Everybody, and especially Antipodeans, knows that there is no rule 6 and by definition what rule 7 is :) -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence --- This email is free from viruses and malware because avast! Antivirus protection is active. http://www.avast.com