How to initialize all the imported modules in PyGame? (original) (raw)

Last Updated : 15 Jul, 2025

PyGameis Python library designed for game development. PyGame is built on the top of SDL library so it provides full functionality to develop game in Python. Pygame has many modules to perform it's operation, before these modules can be used, they must be initialized. All the modules can be initialized individually or one at a time. This post describes how all the imported modules can be initialized at a time.

Methods Used:

Example 1: This example initialize all the pygame modules and print the number of modules initialized successfully.

Python3 `

importing the library

import pygame

initializing all the imported

pygame modules

(numpass,numfail) = pygame.init()

printing the number of modules

initialized successfully

print('Number of modules initialized successfully:', numpass)

`

Output:

Number of modules initialized successfully: 6

Example 2: This example uses pygame.get_init() function to check whether pygame module is initialized or not.

Python3 `

importing the library

import pygame

initializing the modules

pygame.init()

checking the initialization

is_initialized = pygame.get_init()

printing the result

print('Is pygame modules initialized:', is_initialized)

`

Output:

Is pygame modules initialized: True