Why does the Pygame module need to be initialized?


Why does the Pygame module need to be initialized (after importing) so you can properly use it?

Are there any other modules that need to be initialized?

How do you tell if you need to initialize a module or not?

Any answer to any question would be greatly appreciated 🙂


Pygame is not a module. It is a set of modules. There are multiple modules under Pygame.

What pygame.init() does is to initialize all the modules in Pygame. Alternatively, if you initialize only one of the modules, you could do something like pygame.font.init() to initialize just the font module.

With Pygame, you can initialize all modules. There aren’t many.

However, later on, in some cases, the libraries can be massive with a lot more modules, while our project might require only a few. Thus, we would only initialize the modules we need for the project. That is what initialization does, it tells the program what modules to load for us.

Answered By – Arthur H

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published