Avatar ·

Appeal to the function specified in __init__.py

📁 function, Advanced Python Topics, example, AI, project

When initializing the package in Python 2.7, I need to determine the functions that should be common to all modules of this package. I identified them in __init__.py. How to contact it now inside the package? It turns out from the outside:

import package.module
package.foo() #Contact

Inside the package (for example, in the module module), foo is not defined, dir(__package__) also does not display this function.

The structure of the project:

package\ # package
__init__.py