Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.021 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:when': 0.07; 'subject:python': 0.11; 'am,': 0.12; '1:48': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'subject:function': 0.16; 'subject:writing': 0.16; 'wrote:': 0.16; 'arguments': 0.18; 'header:In-Reply-To:1': 0.22; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'values.': 0.23; 'aug': 0.24; 'code': 0.25; 'function': 0.27; 'sat,': 0.28; 'pass': 0.29; '27,': 0.29; 'message-id:@mail.gmail.com': 0.29; 'splitting': 0.30; 'words,': 0.32; 'does': 0.32; 'agree': 0.33; 'probably': 0.33; "can't": 0.33; 'too': 0.33; 'to:addr:python-list': 0.33; 'function.': 0.34; 'explain': 0.36; 'useful': 0.36; 'think': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'subject:: ': 0.39; 'basic': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; "it's": 0.40; 'aids': 0.84; 'subject:any': 0.84; 'subject:there': 0.91 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; bh=i4qq6ienxNnk29QCbAvL1Jh0m1ytUCXpRsKIhQKFri8=; b=dAoB1RuEVOLDFEt7d4Md0gIia4qOQzASqR/R2WwULGTrdEZcwoyLyiW6qKU8FoSb/E U6UYz8hFr47MkSUSVUmrQoMIXrOhYY+0/3e0g15VbSoYPAtY6AD4mba4ewizMznlhQz2 XMGqwLkCO+YcPoGxHKI56CHkrtMG8opd7brV8= MIME-Version: 1.0 In-Reply-To: References: <7b47ca17-d3f1-4d91-91d1-98421e8708cd@ea4g2000vbb.googlegroups.com> Date: Sat, 27 Aug 2011 02:10:34 +1000 Subject: Re: is there any principle when writing python function From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314375037 news.xs4all.nl 2482 [2001:888:2000:d::a6]:39683 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12231 On Sat, Aug 27, 2011 at 1:48 AM, Tobiah wrote: > While I understand and agree with that basic tenet, I think > that the capitalized 'ONLY' is too strong. =A0I do split out > code into function for readability, even when the function > will only be called from the place from which I split it out. > This can be good and can be bad. It's good when it aids readability; it's bad when you need to pass practically the entire locals() as function arguments and/or return values. I would split the function only when both halves (caller and callee) can be given short and useful names - if you can't explain what a block of code does in a few words, it's probably a poor choice for splitting out into a function. ChrisA