Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #48769
| Date | 2013-06-20 13:11 +1000 |
|---|---|
| From | Cameron Simpson <cs@zip.com.au> |
| Subject | Re: Problem with the "for" loop syntax |
| References | <CAPTjJmqJeab8aCihPxbTqhUYkyD089FuftTRLfhMsYTg3J+ZaA@mail.gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.3605.1371697883.3114.python-list@python.org> (permalink) |
On 20Jun2013 11:09, Chris Angelico <rosuav@gmail.com> wrote:
| On Thu, Jun 20, 2013 at 11:02 AM, Arturo B <a7xrturodev@gmail.com> wrote:
| > Fixed, the problem was in
| > HANGMANPICS
| >
| > I didn't open the brackets.
| > Thank you guys :)
|
| General debugging tip: Syntax errors are sometimes discovered quite
| some way below the actual cause. The easiest way to figure out what's
| the real cause is to start cutting away unnecessary code until all
| that's left is the tiniest part that still has the error. This is also
| very helpful as a prerequisite to posting on a list like this, so even
| if you can't find the problem yourself by this method (you often will,
| though), it's well worth doing.
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.
I use vi/vim and it both shows the matching bracket when the cursor
is on one and also have a keystroke to bounce the curser between
this bracket and the matching one.
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.
If you have a syntax highlighting editor (highlights keywords,
colours quoted text differently, etc) it can also be useful for
finding errors; the text will be the wrong colour at some point.
Just a few suggestions to aid finding this kind of thing without
outside help.
Cheers,
--
Cameron Simpson <cs@zip.com.au>
Are you experiencing more Windows95 crashes than the norm? How on earth
would you _know_? - John Brook <johnb@research.canon.com.au>
reporting about a new virus
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Problem with the "for" loop syntax Cameron Simpson <cs@zip.com.au> - 2013-06-20 13:11 +1000
csiph-web