SyntaxError: multiple statements found while compiling a single statement

Cai Gengyang gengyangcai at gmail.com
Sat Oct 8 22:51:52 EDT 2016


This is my latest result : I copy and pasted one line at a time into the IDLE and used ONLY the "enter-return" button to move on to the next line and this time I didnt get an indentation error but instead a traceback error 

>>> rect_x = 50
>>> rect_y = 50
>>> while not done:
	for event in pygame.event.get():
		if event.type == pygame.QUIT:
			done = True

			
Traceback (most recent call last):
  File "<pyshell#12>", line 1, in <module>
    while not done:
NameError: name 'done' is not defined

















On Sunday, October 9, 2016 at 8:15:07 AM UTC+8, Gregory Ewing wrote:
> 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