10/27/2023 0 Comments Pycharm environment variablesOnly when it finds utils can it find file_utils and read_file. In the above example, the import statement would work only if the Python interpreter knows where to look for the first module namely the utils. separating every module is referred as python path syntax. This way of importing modules where you have a. In your main.py if you want to access methods you have defined in file_utils.py you add an import statement in your main.py like this: import utils.file_utils.read_fileĪssuming read_file is the method you want to import into main.py. Let's say your project is structured like this: my_project In Python, when you split your code base across modules, you qualify the name of the import with the name of the module.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |