Q:

How to access whole sub python file from parent in order to use as parameter plus structure of python progr. with modules

I have learned, that I can structure my REUSABLE parts of Python in modules and packages.
But how do I structure a program? Also as a package!?
First, I have my "main.py" program. This is the entry point to my program. Then I want to have
for instance two sub directories "core" and "components" and in "core" a python file named "general.py" with several functions.
How do I access the whole sub python file "general.py" ("core" directory) from the "main.py" file in order to take it as a parameter for a function??
Can anybody show me the possible structure of program with multiple modules?
Thanks alot in advance

A:

Directories work the same as modules, except that they require a __init__.py file in them to be considered as python modules. This file doesn't need to contain anything. To access python modules inside module directories, use a point like
import core.module

At the end you have
main.py
core/
    __init__.py
    module.py

This the simple answer, but actually python packages are more complex than just that and you should read about them.

