How to import module without class in Python?

Viewed 7485

I have 4 files in my project:

project/__init__.py
project/app.py
project/mod_x.py
project/mod_y.py

In mod_x.py I have a class (e.g. ModX) In mod_y.py I have just one function.

I import modules from app.py as follows:

from .mod_x import ModX
import .mod_y

I get an error:

ImportError: No module named 'mod_y'

Before I created init.py I didn't have that kind of problems (of course, I dont put "." before module name).

How to import module which doesn't have the class inside in Python3 with init.py file inside the current directory?

1 Answers
Related