Problem with the "for" loop syntax

Neil Cerutti neilc at norwich.edu
Thu Jun 20 09:55:24 EDT 2013


On 2013-06-20, Joshua Landau <joshua.landau.ws at gmail.com> wrote:
> On 20 June 2013 04:11, Cameron Simpson <cs at zip.com.au> 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.

-- 
Neil Cerutti



More information about the Python-list mailing list