Avatar ·

Calling a function defined in __init__.py

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

When initializing a package in Python 2.7, I need to define functions that should be common to all modules of this package. I defined them in __init__.py. How do I call it from inside the package? From outside it works like this:

import package.modulepackage.foo() # call

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

Project structure:

package\\         # package    __init__.py  # function here    module.py    # I need to call the function here