In particular, let's say I have several .py files with main.py importing things like os, pygame, math and all other .py files, mymodule01.py, etc.
My problem is that whenever main.py calls one of my .py files and this file contains something like os.listdir (), I keep getting an error message saying "os is undefined" .
Should I just import all the necessary modules into each .py file that I write, or is there a better way, for example, centralized import, which each file can recognize? With pygame, this would be very confusing especially since I would have to initialize pygame in each file, just to use its functions, not to mention if I want something on the screen.
The documentation on python modules and packages did not help much, it is either very slow, and also considering that after the document is executed, I continue to receive an error not found after adding, for example, import the mymodule01.py file in the init .py file in the folder in which .
source share