SyntaxError: multiple statements found while compiling a single statement

Cai Gengyang gengyangcai at gmail.com
Sat Oct 8 03:47:59 EDT 2016


This is the result when I copy and paste it one line at a time :

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








On Saturday, October 8, 2016 at 3:02:09 PM UTC+8, Steve D'Aprano wrote:
> On Sat, 8 Oct 2016 05:29 pm, Cai Gengyang wrote:
> 
> > Unfortunately, in this case, it is 100% of the information I am giving
> > you. 
> 
> Exactly. That's the problem. You need to give us more information, like how
> you are trying to run this code. Are you using an IDE? Which IDE?
> 
> 
> > You can try it yourself. The code is in the first section (8.1) of 
> > 
> >
> http://programarcadegames.com/index.php?chapter=introduction_to_animation&lang=en#section_8
> > 
> > Just copy and paste it into your Python IDLE and let me know what you get
> 
> 
> I don't normally use IDLE, and you shouldn't assume that everyone does.
> *That* is the extra information we need to solve the problem:
> 
> The IDLE interactive interpreter in Python 3 does not seem to allow you to
> paste multiple lines at once. If you do, it highlights the first line of
> code with a red background and prints the error:
> 
> SyntaxError: multiple statements found while compiling a single statement
> 
> 
> 
> For example:
> 
> 
> Python 3.3.0rc3 (default, Sep 27 2012, 18:44:58) 
> [GCC 4.1.2 20080704 (Red Hat 4.1.2-52)] on linux
> Type "copyright", "credits" or "license()" for more information.
> >>> # Define some colors
> BLACK = (0, 0, 0)
> WHITE = (255, 255, 255)
> GREEN = (0, 255, 0)
> RED = (255, 0, 0)
> SyntaxError: multiple statements found while compiling a single statement
> >>> 
> 
> 
> 
> I can't show the colour highlighting, but the line BLACK = ... is
> highlighted in red.
> 
> 
> You can either copy and paste one line at a time, or you can use the File >
> Open menu command to open a complete script.
> 
> 
> 
> 
> 
> 
> -- 
> Steve
> “Cheer up,” they said, “things could be worse.” So I cheered up, and sure
> enough, things got worse.




More information about the Python-list mailing list