Python Forum
EOF while parsing - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: EOF while parsing (/thread-32347.html)



EOF while parsing - Leo_Red - Feb-04-2021

Hi, so I am starting to get some unusual errors on some of my python scripts. it randomly giving an error like "IndentationError: expected an indented block" when I add a new line. So, then I remove that line and it gives the same error on the next line, and I keep repeating it until there is no lines left, then it says "EOF while parsing". I tried reopening the code editor (VS code), but it did not work. This is really getting annoying as there is nothing I can do to fix it.

Here is the most recent script that it gave the error:

#------------------------ Import Bay ------------------------
import pygame
#------------------------ loading bay------------------------

pencil = pygame.image.load("Assets/tools/Pencil_tool/Pencil_tool_icon(Large)-export.png")
eraser = pygame.image.load("Assets/tools/Eraser_tool/Eraser_tool.png")



#------------------------ Variable Bay------------------------

version = "0.0.1"
running = True
current_tool = 0
colour = (255,255,255)


#------------------------Init Bay------------------------


pygame.init()


screen = pygame.display.set_mode((800,600))
canvas =  pygame.Surface((64, 64))
pre_show = pygame.Surface((64, 64))
pygame.display.set_caption("Pyxe")
icon = pygame.image.load("Assets/icons3.png")
pygame.display.set_icon(icon)


#------------------------Main Loop------------------------

screen.fill((62,53,70))
while running:
    pre_show.fill((0,0,0,0))
    mouse = pygame.mouse.get_pos()
    mouse_buttons = pygame.mouse.get_pressed()
    scaled_pos = (mouse[0] - 336, mouse[1] - 236 )
    pre_show.fill((0,0,0,0))
    
    
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            running = False
    
        if mouse_buttons[1]:
            pygame.draw.line(pre_show, colour ,(0,  0), scaled_pos)
        
        if event.type == pygame.MOUSEBUTTONUP:
            
    
    screen.blit(pre_show, (336, 236))
    screen.blit(canvas, (336, 236))
    screen.blit(pencil, (734, 60))
    screen.blit(eraser, (734, 120))
Here is the most recent error:

Error:
screen.blit(pre_show, (336, 236)) ^ IndentationError: expected an indented block
Thanks for helping



RE: EOF while parsing - deanhystad - Feb-04-2021

Th last if statement needs a body. At the very least a docstring or pass statement. As it is the parser uses the next line as the body and complains the indent is wrong.


RE: EOF while parsing - Leo_Red - Feb-05-2021

(Feb-04-2021, 02:19 PM)Leo_Red Wrote: Hi, so I am starting to get some unusual errors on some of my python scripts. it randomly giving an error like "IndentationError: expected an indented block" when I add a new line. So, then I remove that line and it gives the same error on the next line, and I keep repeating it until there is no lines left, then it says "EOF while parsing". I tried reopening the code editor (VS code), but it did not work. This is really getting annoying as there is nothing I can do to fix it.

Here is the most recent script that it gave the error:

#------------------------ Import Bay ------------------------
import pygame
#------------------------ loading bay------------------------

pencil = pygame.image.load("Assets/tools/Pencil_tool/Pencil_tool_icon(Large)-export.png")
eraser = pygame.image.load("Assets/tools/Eraser_tool/Eraser_tool.png")



#------------------------ Variable Bay------------------------

version = "0.0.1"
running = True
current_tool = 0
colour = (255,255,255)


#------------------------Init Bay------------------------


pygame.init()


screen = pygame.display.set_mode((800,600))
canvas =  pygame.Surface((64, 64))
pre_show = pygame.Surface((64, 64))
pygame.display.set_caption("Pyxe")
icon = pygame.image.load("Assets/icons3.png")
pygame.display.set_icon(icon)


#------------------------Main Loop------------------------

screen.fill((62,53,70))
while running:
    pre_show.fill((0,0,0,0))
    mouse = pygame.mouse.get_pos()
    mouse_buttons = pygame.mouse.get_pressed()
    scaled_pos = (mouse[0] - 336, mouse[1] - 236 )
    pre_show.fill((0,0,0,0))
    
    
    for event in pygame.event.get():

        if event.type == pygame.QUIT:
            running = False
    
        if mouse_buttons[1]:
            pygame.draw.line(pre_show, colour ,(0,  0), scaled_pos)
        
        if event.type == pygame.MOUSEBUTTONUP:
            
    
    screen.blit(pre_show, (336, 236))
    screen.blit(canvas, (336, 236))
    screen.blit(pencil, (734, 60))
    screen.blit(eraser, (734, 120))
Here is the most recent error:

Error:
screen.blit(pre_show, (336, 236)) ^ IndentationError: expected an indented block
Thanks for helping

Thanks a lot Heart Now it works!!