SyntaxError: multiple statements found while compiling a single statement

Gregory Ewing greg.ewing at canterbury.ac.nz
Sat Oct 8 20:14:52 EDT 2016


Cai Gengyang wrote:
> Somehow it still doesnt work --- it keeps giving the syntaxerror,
> inconsistent use of tabs and indentation message EVEN though i use only the
> enter and space buttons and never touched the tab button a single time.

There was another thread about this a short time ago.
It turns out that when you press enter in the IDLE REPL,
it auto-indents the next line -- but it does it using
*tabs*, not spaces. So if you do your manual indentation
with spaces, or paste something in that uses spaces, you
can easily end up with invalid tab/space mixtures.

The solution is to always use the tab key for indentation
when working interactively in IDLE.

I think this should be reported as a bug in IDLE, because
it's very unintuitive behaviour, and a beginner has little
chance of figuring out what's going on by themselves.

-- 
Greg




More information about the Python-list mailing list