Big Python includes

I have a file that I want to include in Python, but the included file is quite long, and it would be much neater to split them into several files, but then I need to use several include statements.

Is there a way to group multiple files and include them at once?

+3
source share
2 answers
  • Put the files in one folder.
  • Add the __init__.py file to the folder. Necessary import in __init __. Py
  • Replace multiple imports with one:

    import folder_name

See Python Package Management

+8
source

Yes, see the “6.4 Packages” section at http://docs.python.org/tut/node8.html :

, __init__.py . PYTHONPATH sys.path, "import directoryname", "import directoryname.some_file_in_directory" , .

__init__.py , Python ; , , "", , . __init__.py , __all__, .

+6

Source: https://habr.com/ru/post/1696764/


All Articles