Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!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; ':-)': 0.06; 'subject:when': 0.07; 'suggesting': 0.07; 'ugly': 0.07; 'used.': 0.07; '*i*': 0.09; '*you*': 0.09; 'cleaned': 0.09; 'readable': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:python': 0.11; 'bullet': 0.16; 'cleanup.': 0.16; 'debugged': 0.16; 'executed.': 0.16; 'he,': 0.16; 'received:173.11': 0.16; 'roy': 0.16; 'subject:function': 0.16; 'subject:writing': 0.16; 'looked': 0.16; 'written': 0.16; 'wrote:': 0.16; 'wrote': 0.20; 'figure': 0.21; 'later': 0.21; 'header:In-Reply-To:1': 0.22; 'expectation': 0.23; 'minutes,': 0.23; "shouldn't": 0.23; 'code': 0.25; 'code.': 0.26; "i'm": 0.27; 'code,': 0.28; "he's": 0.29; 'fix': 0.29; '"who': 0.30; 'now?': 0.30; 'standards': 0.31; "didn't": 0.31; 'chris': 0.32; 'coding': 0.32; "can't": 0.33; 'to:addr:python-list': 0.33; "i've": 0.34; 'header:User-Agent:1': 0.34; 'spent': 0.34; 'structured': 0.34; 'header:X-Complaints-To:1': 0.35; 'but': 0.37; 'two': 0.37; 'received:org': 0.38; 'some': 0.38; 'move': 0.38; 'subject:: ': 0.39; 'getting': 0.39; 'header:Mime-Version:1': 0.39; "there's": 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'might': 0.40; "it's": 0.40; 'history': 0.40; 'more': 0.60; 'your': 0.61; 'six': 0.61; 'needing': 0.64; 'minutes': 0.64; 'discover': 0.67; 'view': 0.67; '"can': 0.84; '"will': 0.84; 'adhere': 0.84; 'checkin': 0.84; 'subject:any': 0.84; 'reasons:': 0.91; 'subject:there': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Emile van Sebille Subject: Re: is there any principle when writing python function Date: Sat, 27 Aug 2011 10:27:48 -0700 References: <7b47ca17-d3f1-4d91-91d1-98421e8708cd@ea4g2000vbb.googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: 173-11-108-137-sfba.hfc.comcastbusiness.net User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:6.0) Gecko/20110812 Thunderbird/6.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 39 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314466082 news.xs4all.nl 2416 [2001:888:2000:d::a6]:60647 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12279 On 8/27/2011 9:41 AM Roy Smith said... > Chris Angelico wrote: > >> the important >> considerations are not "will it take two extra nanoseconds to execute" >> but "can my successor understand what the code's doing" and "will he, >> if he edits my code, have a reasonable expectation that he's not >> breaking stuff". These are always important. > > Forget about your successor. Will *you* be able to figure out what you > did 6 months from now? I can't tell you how many times I've looked at > some piece of code, muttered, "Who wrote this crap?" and called up the > checkin history only to discover that *I* wrote it :-) When you consider that you're looking at the code six months later it's likely for one of three reasons: you have to fix a bug; you need to add features; or the code's only now getting used. So you then take the extra 20-30 minutes, tease the code apart, refactor as needed and end up with better more readable debugged code. I consider that the right time to do this type of cleanup. For all the crap I write that works well for six months before needing to be cleaned up, there's a whole lot more crap that never gets looked at again that I didn't clean up and never spent the extra 20-30 minutes considering how my future self might view what I wrote. I'm not suggesting that you shouldn't develop good coding habits that adhere to established standards and result in well structured readable code, only that if that ugly piece of code works that you move on. You can bullet proof it after you uncover the vulnerabilities. Code is first and foremost written to be executed. Emile