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.erje.net!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.022 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'interpreter': 0.05; 'subject:Python': 0.05; 'coders': 0.07; 'python': 0.08; '*is*': 0.09; 'okay': 0.09; 'message-----': 0.12; 'def': 0.13; 'code?': 0.16; 'explanation': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.18; 'java': 0.21; 'to:2**1': 0.21; 'dec': 0.22; 'header:In-Reply-To:1': 0.22; 'indentation': 0.23; 'code': 0.25; 'code.': 0.26; "i'm": 0.26; 'url:mailman': 0.28; 'comfortable': 0.28; 'looks': 0.29; 'class': 0.29; 'beauty': 0.30; 'casual': 0.30; "i've": 0.31; 'thu,': 0.32; 'url:listinfo': 0.32; "can't": 0.32; 'to:addr:python-list': 0.34; 'probably': 0.34; 'subject:': 0.34; 'elegant': 0.34; 'try:': 0.34; 'languages': 0.35; 'url:python': 0.36; 'starting': 0.36; 'sent:': 0.36; 'beginning': 0.36; '...': 0.36; 'charset:us-ascii': 0.37; 'skip:p 50': 0.37; 'thursday,': 0.37; 'but': 0.37; 'reference': 0.37; 'received:192': 0.37; 'think': 0.37; 'using': 0.38; 'steven': 0.38; 'received:org': 0.38; 'from:': 0.39; 'url:org': 0.39; 'should': 0.39; 'why': 0.39; 'help!': 0.40; 'to:addr:python.org': 0.40; 'received:192.168': 0.40; 'management': 0.60; 'more': 0.61; '2011': 0.61; 'your': 0.61; 'deeply': 0.64; 'ever': 0.65; 'spaces': 0.73; 'saving': 0.76; 'code;': 0.84; 'deep,': 0.84; 'seen.': 0.84; 'subject:Reference': 0.84 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: Using the Python Interpreter as a Reference Date: Fri, 2 Dec 2011 15:29:22 -0500 In-Reply-To: <4ed81f16$0$29988$c3e8da3$5496439d@news.astraweb.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Using the Python Interpreter as a Reference Thread-Index: Acywi9JjifHP2imLQ0GTOkSBBb8rqQApRTbg References: <79379487-0081-4067-92ed-c6717652e1ff@y7g2000vbe.googlegroups.com><4eb0af60-26b3-45d5-8aff-566505003d6a@m10g2000vbc.googlegroups.com><4ed2cddc$0$29988$c3e8da3$5496439d@news.astraweb.com><4ed491fe$0$14018$c3e8da3$76491128@news.astraweb.com> <4ed81f16$0$29988$c3e8da3$5496439d@news.astraweb.com> From: "Sells, Fred" To: "Steven D'Aprano" , 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: 70 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1322857841 news.xs4all.nl 6982 [2001:888:2000:d::a6]:59457 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:16569 Steven, that's probably the most elegant explanation of the "pythonic" way I've ever seen. I'm saving it for the next time upper management want to use Java again. -----Original Message----- From: python-list-bounces+frsells=3Dadventistcare.org@python.org [mailto:python-list-bounces+frsells=3Dadventistcare.org@python.org] On Behalf Of Steven D'Aprano Sent: Thursday, December 01, 2011 7:43 PM To: python-list@python.org Subject: Re: Using the Python Interpreter as a Reference On Thu, 01 Dec 2011 10:03:53 -0800, DevPlayer wrote: [...] > Well, that may be a little hyperbolic. But with 2 spaces you can > encourage coders to get very deep, indentially, and still fit 80 chars. Why would you want to encourage coders to write deeply indented code? In my opinion, if your code is indented four or more levels, you should=20 start to think about refactorising your code; if you reach six levels,=20 your code is probably a mess. class K: def spam(): if x: for a in b: # This is about as deep as comfortable while y: # Code is starting to smell try: # Code smell is now beginning to reek with z as c: # And now more of a stench try: # A burning, painful stench if d: # Help! I can't breathe!!! for e in f: # WTF are you thinking? try: # DIE YOU M***********ER!!! while g: # gibbers quietly ... The beauty of languages like Python where indentation is significant is=20 that you can't hide from the ugliness of this code.=20 class K: { # Code looks okay to a casual glance. def spam():{ if x: { for a in b:{ while y:{ try:{ with z as c:{ try:{ if d:{ for e in f:{ try:{ while g:{ ... }}}} }}}} }}}} Deeply indented code *is* painful, it should *look* painful. --=20 Steven --=20 http://mail.python.org/mailman/listinfo/python-list