Python IDLE file editor thinks I want more auto-indent than I do

394 views Asked by At

I have a bit over 500 lines of code-plus-comments that I've written over the past few days. It runs (see edit), and does what it's supposed to. But whenever I hit enter after any text, IDLE fills in whitespace to column 28. If I go from column 28 and type a line that should need more indentation, for example For i in range(25):, and hit enter, it still only indents to column 28.

When I edit a new file, it indents the right amount. When I try extending a logical line to multiple physical lines, it still indents the right amount. But when I copy-and-paste my 500-plus lines into the new file, it goes back to filling in whitespace to column 28. When I change the number of spaces to indent to 6 (from the standard 4), it still goes to column 28: it just deletes the whitespace 6 at a time when I hit backspace instead of 4.

There are a bunch of logical lines continued to multiple physical lines, scattered through my code, but they all seem to be just like the ones I've tried in a new file and had it work right. I assume that one of them is different somehow, so that IDLE file-editor thinks I still want to continue it from column 28, but I don't see any difference.

I'm using Python 3.4.3 on Windows 8.1.

Edit: I was thinking I was looking at a version that ran, but I wasn't. The accepted answer was correct, and there was a mismatched parenthesis on column 28 in the code I was adding.

1

There are 1 answers

0
Douglas On BEST ANSWER

Your parentheses/brackets/something else are most likely unbalanced on a previous line of code (I'll call it a parentheses). The open parentheses that does not have a closing one is likely on column 28.