Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed5.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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:when': 0.07; 'executed': 0.09; 'machines.': 0.09; 'of)': 0.09; 'situation,': 0.09; 'subject:python': 0.11; 'am,': 0.12; '*cannot*': 0.16; 'executed.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'messy': 0.16; 'non-trivial': 0.16; 'subject:function': 0.16; 'subject:writing': 0.16; 'written': 0.16; 'wrote:': 0.16; 'primarily': 0.21; 'discussion': 0.22; 'header:In-Reply-To:1': 0.22; '(or': 0.23; 'received:209.85.213.46': 0.23; 'received:mail- yw0-f46.google.com': 0.23; 'noticed': 0.24; 'aug': 0.24; 'code': 0.25; 'code.': 0.26; "i'm": 0.27; 'fact': 0.27; 'explicitly': 0.29; 'message-id:@mail.gmail.com': 0.29; 'specifically': 0.29; 'context,': 0.30; 'operation.': 0.30; 'sun,': 0.30; 'track,': 0.30; 'error': 0.32; 'filled': 0.32; 'pages,': 0.32; 'usually': 0.32; 'there': 0.33; 'to:addr:python-list': 0.33; 'that,': 0.33; 'checking': 0.34; 'sometimes,': 0.34; 'put': 0.37; 'but': 0.37; 'steven': 0.38; 'some': 0.38; 'received:google.com': 0.38; 'received:209.85': 0.38; 'easier': 0.38; 'subject:: ': 0.39; 'goes': 0.39; "there's": 0.39; 'data': 0.39; 'to:addr:python.org': 0.39; "it's": 0.40; 'where': 0.40; 'one,': 0.40; 'six': 0.61; 'world': 0.62; 'perfect': 0.63; 'human': 0.63; 'believe': 0.65; 'production': 0.70; 'validation': 0.73; 'forums': 0.77; 'beautiful': 0.80; 'code;': 0.84; 'consumed': 0.84; 'quantities': 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; bh=Wf/fM3b6M071bV87i/kpU82Pf7K/H3paAngTO34dJmM=; b=Q+gpNbA6lYrCB+OEvjjJ8+fn4e+YaKOPKI77A2F6ov4ySgrzYv8HZSTZiLoLxhVxC8 S7CKlN0VMwqQeAoR1H3Bl+u3jy07Z85ISUhMjks1H29DvGE30dk08CDKcKXzj2qBkDS3 5Em+NQ+jY3AWYUbrlh//mAgPlR2ujPZwk9vFc= MIME-Version: 1.0 In-Reply-To: <4e595334$0$30000$c3e8da3$5496439d@news.astraweb.com> References: <7b47ca17-d3f1-4d91-91d1-98421e8708cd@ea4g2000vbb.googlegroups.com> <4e595334$0$30000$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 28 Aug 2011 06:38:31 +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 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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314477514 news.xs4all.nl 2407 [2001:888:2000:d::a6]:42056 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12298 On Sun, Aug 28, 2011 at 6:27 AM, Steven D'Aprano wrote: > You've never noticed the masses of code written in text books, blogs, web > pages, discussion forums like this one, etc.? > > Real world code for production is usually messy and complicated and filled > with data validation and error checking code. There's a lot of code without > that, because it was written explicitly to be read by humans, and the fact > that it may be executed as well is incidental. Some code is even written in > pseudo-code that *cannot* be executed. It's clear to me that a non-trivial > amount of code is specifically written to be consumed by other humans, not > by machines. Yes, I'm aware of the quantities of code that are primarily for human consumption. But in the original context, which was of editing code six months down the track, I still believe that such code is primarily for the machine. In that situation, there are times when it's not worth the hassle of writing beautiful code; you'd do better to just get that code generated and in operation. Same goes for lint tools and debuggers - sometimes, it's easier to just put the code into a live situation (or a perfect copy of) and see where it breaks, than to use a simulation/test harness. ChrisA