Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8228243
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T16:23:57+00:00 2026-06-07T16:23:57+00:00

I am learning to use Pygame, and when I use sys.exit() , I run

  • 0

I am learning to use Pygame, and when I use sys.exit(), I run into a problem. Here is the code:

import pygame, sys,os
from pygame.locals import * 

pygame.init() 

window = pygame.display.set_mode((468, 60)) 
pygame.display.set_caption('Game') 
screen = pygame.display.get_surface() 

file_name = os.path.join("data","image.bmp")

surface = pygame.image.load(file_name)

screen.blit(surface, (0,0)) 
pygame.display.flip() 

def input(events): 
   for event in events: 
      if event.type == QUIT: 
         sys.exit(0) 
      else: 
         print event 

while True: 
   input(pygame.event.get()) 

It’s really just the code from the pygame tutorial. The problem occurs when I actually try to exit, regardless of what event I try to use to sys.exit().

Traceback (most recent call last):
  File "C:/Python27/Lib/site-packages/pygame/examples/test.py", line 25, in <module>
    input(pygame.event.get())
  File "C:/Python27/Lib/site-packages/pygame/examples/test.py", line 20, in input
    sys.exit(0)
SystemExit: 0

… And then the program doesn’t exit. What am I doing wrong here? Because I did notice that this code was for an antiquated version of Python.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T16:23:59+00:00Added an answer on June 7, 2026 at 4:23 pm

    sys.exit just throws an exception (a SystemExit exception). This has two unusual effects:

    1. It only exits the current thread in a multithreaded application
    2. The exception could have been caught.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am learning to use Boost ASIO. Here is some code copied from the
I am learning to use xmlhttprequest/AJAX. In this sample code from w3schools, I do
I have the following Python (3.2) code: from pygame import * class Application: def
I am learning to use DelgateCommand from Prism.... In my UI, I have my
Learning to use Ruby Threads for transportability of code between different OS platforms. The
I am learning to use mahout by starting with a example copied from the
I am learning to use shaders in OpenGL ES. As an example: Here's my
I've just started learning how to use pygame yesterday. I was read this one
I learning to use Pointers. I have a few questions about an exercise code
I have been learning to use a slideshow code I saw on a website

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.