Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.007 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'feedback.': 0.04; 'syntax': 0.04; 'insert': 0.05; 'feature,': 0.09; 'python': 0.11; 'bug': 0.12; '(syntax': 0.16; 'adjacent': 0.16; 'backspace': 0.16; 'braces': 0.16; 'bracket,': 0.16; 'brackets': 0.16; 'buggy': 0.16; 'colon.': 0.16; 'expect,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'half.': 0.16; 'indent': 0.16; 'notation.': 0.16; 'simpson': 0.16; 'subject:Problem': 0.16; 'ternary': 0.16; 'top:': 0.16; 'fix': 0.17; 'wrote:': 0.18; 'first.': 0.19; "python's": 0.19; 'thu,': 0.19; '>>>': 0.22; 'error': 0.23; 'instance,': 0.24; 'earlier': 0.24; '(or': 0.24; "i've": 0.25; 'handling': 0.26; 'nearly': 0.26; 'code:': 0.26; 'header:In-Reply-To:1': 0.27; 'feature': 0.29; '(like': 0.30; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; 'usually': 0.31; 'indentation': 0.31; 'void': 0.31; 'quite': 0.32; 'actual': 0.34; 'subject:the': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'editor': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'found.': 0.36; 'thanks': 0.36; "i'll": 0.36; 'two': 0.37; 'area': 0.37; 'expected': 0.38; 'skip:o 20': 0.38; 'same.': 0.38; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'that,': 0.38; 'quote': 0.39; 'subject:" ': 0.39; 'to:addr:python.org': 0.39; 'space': 0.40; 'even': 0.60; 'blank': 0.60; 'is.': 0.60; 'middle': 0.60; 'skip:t 30': 0.61; 'kind': 0.63; 'valuable': 0.63; 'due': 0.66; 'bottom': 0.67; 'close': 0.67; '20,': 0.68; 'line,': 0.68; 'press': 0.70; 'or...': 0.84; 'technique.': 0.84; 'mistake': 0.91; 'imagine': 0.93; 'instant': 0.97; '2013': 0.98 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=q90oG4qTERbK0XDVLDhI+1jBxymY9AeCnL1Pf0y+na8=; b=KNdpUSgNM+2mQttKmH+ReryVznIeyrCqJ9JP8dJmI+RRTeRTyV0uoY8CdoTPz3uiwK s9HX9WE77uERPVoN0yPV3hTAvXnvlVZj65c3CWREcMmE0kIC0+vg7rf5J2vpZ6/KK3/T /3ZcywUhlOs/RCdGzfphK+iJo/H0mu/58jMNIORnnsIGUt2JeYvrUw5WxcV+I//YX82/ oaj6Em+WdRZ9zyghhcBdVnoR8JHXUp5XdwARN0gcoGxsu9h4Xbq09W1NwRhNZ+51iaJ/ 7/aWA/8EUo/++2Gedwb2MarkGMSXHGv3uburlkn1PteqWj+Ro5XcXF2Z5C7RxtVUBiDR q3fA== MIME-Version: 1.0 X-Received: by 10.58.144.105 with SMTP id sl9mr3272660veb.98.1371743127071; Thu, 20 Jun 2013 08:45:27 -0700 (PDT) In-Reply-To: References: <20130620031113.GA85034@cskk.homeip.net> Date: Fri, 21 Jun 2013 01:45:27 +1000 Subject: Re: Problem with the "for" loop syntax 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.15 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: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1371743604 news.xs4all.nl 15864 [2001:888:2000:d::a6]:49674 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:48804 On Thu, Jun 20, 2013 at 11:55 PM, Neil Cerutti wrote: > On 2013-06-20, Joshua Landau wrote: >> On 20 June 2013 04:11, Cameron Simpson wrote: >>> Also, opening-and-not-closing a set of brackets is almost the >>> only way in Python to make this kind of error (syntax at one >>> line, actual mistake far before). >>> >>> See if your editor has a show-the-matching-bracket mode. >>> If you suspect you failed to close a bracket, one approach is >>> to go _below_ the syntax error (or right on it) and type a >>> closing bracket. Then see where the editor thinks the opening >>> one is. >> >> Thanks for that, that's quite an ingenious technique. > > The auto-indent feature of Vim catches this type of syntax error, > and I imagine other good autoindent support will do the same. > After I press enter and the following line's indent isn't what I > expect, it is nearly always due to a missing bracket, quote or > colon. > > So if you press enter and the autoindent is unexpected, don't > just press space or backspace to fix it. It's usually a sign of > an earlier syntax error, so look for that first. Yes, though editors (like everything else!) can be buggy - SciTE, for instance, has a bug with handling two adjacent braces in C code: void dummy_function() {} //SciTE will indent after that line But autoindentation is a *hugely* valuable feature, because it gives INSTANT feedback. You hit enter, the line is indented, you expected no indent, problem found. And I've even used it as a means of probing - if there's a problem in this area somewhere, I just go to the middle of the area, hit enter to insert a blank line, and see if the indentation is wrong. If it is, the problem's in the top half, else the problem's in the bottom half. That is: The problem is in the top-if-indentation-wrong-else-bottom half, using Python's ternary syntax. Or the (indentation-wrong? top: bottom) half, in C notation. Or... okay, I'll stop now. ChrisA