Skip to content
Advertisement

How do I assign the types for python-modules?

Here is an example with pygame (Types do not get inferred):

import pygame

pygame.display.set_mode((size))

Types do get inferred:

from pygame import display

display.set_mode((size))

Well, this library throws an error when importing single modules and using pygame.init(). Is there another way to use the first example and type the modules afterwards?

Advertisement

Answer

from pygame import * is the best thing to use in this situation.

In your situation, init() can be simply used along with display.set_mode((size)) and any other objects within the pygame module.

This is due to the fact that import * imports the module and makes reference to all the public objects defined by the module (Reference).

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement