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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'chunk': 0.07; 'subject:when': 0.07; 'also:': 0.09; 'content- type:multipart/signed': 0.09; 'filename:fname piece:signature': 0.09; 'functioning': 0.09; 'interpreting': 0.09; 'low.': 0.09; 'run.': 0.09; 'subject:python': 0.11; '"and': 0.16; '(at)': 0.16; '(dot)': 0.16; 'aesthetic': 0.16; 'bugs,': 0.16; 'cares': 0.16; 'content-type:application/pgp-signature': 0.16; "doesn't.": 0.16; 'enlighten': 0.16; 'executed,': 0.16; 'executed.': 0.16; 'filename:fname piece:asc': 0.16; 'filename:fname:signature.asc': 0.16; 'finney': 0.16; 'messy': 0.16; 'overly': 0.16; 'pythonic': 0.16; 'refactoring': 0.16; 'subject:function': 0.16; 'subject:writing': 0.16; 'sure,': 0.16; 'this:': 0.16; 'written': 0.16; 'wrote:': 0.16; '>>>': 0.18; 'enormous': 0.18; 'written,': 0.18; 'seems': 0.20; 'later': 0.21; 'blog:': 0.21; "doesn't": 0.22; 'header:In-Reply-To:1': 0.22; 'obviously': 0.23; 'runs': 0.23; 'emphasis': 0.23; "one's": 0.23; 'works.': 0.23; 'pm,': 0.24; 'do,': 0.25; 'code': 0.25; 'writes:': 0.25; 'code.': 0.26; 'fine': 0.26; 'van': 0.26; 'bugs': 0.28; 'concern': 0.28; 'right.': 0.28; 'stage': 0.29; 'fixed': 0.29; 'looks': 0.29; 'fix': 0.29; 'hansen': 0.30; 'certainly': 0.32; 'received:24': 0.32; 'does': 0.32; "isn't": 0.33; 'it.': 0.33; 'actually': 0.33; 'to:addr:python-list': 0.33; 'however,': 0.34; 'community': 0.34; '...': 0.34; 'nobody': 0.34; 'quite': 0.34; 'idea': 0.34; 'test': 0.34; 'audience.': 0.34; 'pretty': 0.35; 'rather': 0.35; 'supposed': 0.35; 'unless': 0.36; 'read,': 0.36; 'doing': 0.36; 'later,': 0.37; 'offset': 0.37; 'reasons': 0.37; 'but': 0.37; 'something': 0.37; 'not,': 0.38; 'amounts': 0.38; 'some': 0.38; 'received:google.com': 0.38; 'should': 0.38; 'subject:: ': 0.39; 'correctly': 0.39; 'difficult': 0.39; 'help': 0.39; 'goes': 0.39; 'why': 0.39; 'to:addr:python.org': 0.39; 'received:74.125': 0.39; 'greatly': 0.40; 'more': 0.60; 'easily': 0.61; 'your': 0.61; 'body': 0.61; 'back': 0.62; 'free': 0.63; 'ever': 0.65; 'making': 0.67; 'prime': 0.67; 'header:Reply-To:1': 0.71; 'reply-to:no real name:2**0': 0.71; 'attention.': 0.73; 'mail:': 0.73; 'also...': 0.84; 'processor.': 0.84; 'readability': 0.84; 'something.': 0.84; 'subject:any': 0.84; 'vastly': 0.84; 'poorly': 0.91; 'subject:there': 0.91; 'organized,': 0.93; 'url:io': 0.93; 'beneficial': 0.95 Sender: Ixokai Date: Sat, 27 Aug 2011 16:27:16 -0700 From: Stephen Hansen MIME-Version: 1.0 To: python-list@python.org Subject: Re: is there any principle when writing python function References: <7b47ca17-d3f1-4d91-91d1-98421e8708cd@ea4g2000vbb.googlegroups.com> <87vctitt43.fsf@benfinney.id.au> In-Reply-To: X-Enigmail-Version: 1.1.1 OpenPGP: id=555B1FE5; url=http://id.ixokai.io/pub.asc Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig0F25C1AAB0CD1E2FD4C9B5FE" X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: me+list/python@ixokai.io 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: 111 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1314487653 news.xs4all.nl 2514 [2001:888:2000:d::a6]:34241 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:12317 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0F25C1AAB0CD1E2FD4C9B5FE Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 8/27/11 3:21 PM, Emile van Sebille wrote: > On 8/27/2011 2:57 PM Ben Finney said... >> Emile van Sebille writes: >> >>> Code is first and foremost written to be executed. >> >=20 >=20 >> =E2=80=9CPrograms must be written for people to read, and only >> incidentally for >> machines to execute.=E2=80=9D >> =E2=80=94Abelson& Sussman, _Structure and Interpretation of Comp= uter >> Programs_ >> >=20 > That's certainly self-fulfilling -- code that doesn't execute will need= > to be read to be understood, and to be fixed so that it does run. Nobod= y > cares about code not intended to be executed. Pretty it up as much as > you have free time to do so to enlighten your intended audience. Er, you're interpreting the quote... way overboard. No one's talking about code that isn't intended to be executed, I don't think; the quote includes, "and only incidentally for machines to execute." That's still the there, and its still important. It should just not be the prime concern while actually writing the code. The code has to actually do something. If not, obviously you'll have to change it. The Pythonic emphasis on doing readable, pretty code isn't JUST about making code that just looks good; its not merely an aesthetic that the community endorses. And although people often tout the very valid reason why readability counts-- that code is often read more then written, and that coming back to a chunk of code 6 months later and being able to understand fully what its doing is very important... that's not the only reason readability counts. Readable, pretty, elegantly crafted code is also far more likely to be *correct* code. However, this: > Code that runs from the offset may not ever again need to be read, so > the only audience will ever be the processor. >=20 > I find it much to easy to waste enormous amounts of time prettying up > code that works. Pretty it up when it doesn't -- that's the code that > needs the attention. =2E.. seems to me to be a rather significant self-fulfilling prophecy in its own right. The chances that the code does what its supposed to do, accurately, and without any bugs, goes down in my experience quite significantly the farther away from "pretty" it is. If you code some crazy, overly clever, poorly organized, messy chunk of something that /works/ -- that's fine and dandy. But unless you have some /seriously/ comprehensive test coverage then the chances that you can eyeball it and be sure it doesn't have some subtle bugs that will call you back to fix it later, is pretty low. In my experience. Its not that pretty code is bug-free, but code which is easily read and understood is vastly more likely to be functioning correctly and reliably= =2E Also... it just does not take that much time to make "pretty code". It really doesn't. The entire idea that its hard, time-consuming, effort-draining or difficult to make code clean and "pretty" from the get-go is just wrong. You don't need to do a major "prettying up" stage after the fact. Sure, sometimes refactoring would greatly help a body of code as it evolves, but you can do that as it becomes beneficial for maintenance reasons and not just for pretty's sake. --=20 Stephen Hansen ... Also: Ixokai ... Mail: me+list/python (AT) ixokai (DOT) io ... Blog: http://meh.ixokai.io/ --------------enig0F25C1AAB0CD1E2FD4C9B5FE Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.10 (Darwin) iQEcBAEBAgAGBQJOWX1YAAoJEKcbwptVWx/lQuMH/At1QkTrnFHogXwu1tK3uYcP vmq6UKOtIhDmD225qGfmUnAQ5+GEoDHxdNWZKW/VckU1nR2NMjxLdfkjWIiGRslw JI8LJaJ17TrSptmdJAxY/r0WvEYEPK2CGEurAU9etDiREry5BnvB7AiabW3/Rgzx vPp9qA4lUHHokF2RGV97cq9HBA+1dKIsBCIUl0tfEdTn675HXKlJOvxpWCBUehOi kee6fprCT3wyFLeVp8RJv3SNJJgsTPRZ+p47nin6to3bHDxXOcvHqshDYm66JPLm 5DWRWDagaGb3o/QmOHRtr/mrIr86ggn2flzjtvsI2gleHio8uxTI+9TtapUV70g= =MvCo -----END PGP SIGNATURE----- --------------enig0F25C1AAB0CD1E2FD4C9B5FE--