I am having problems to organize the project structure and successfully run the program. I dont want to use the sys.path module, so I choose to create init.py files. But i notice redundancy and I am confused how to properly do this. Other packages need also modules of neighbored packages.
src
- __init__.py
- main.py
- data
-- __init__.py
-- data_loader.py
- util
-- __init__.py
-- stringUtil.py
_init_.py
import .data
import .util
main.py
from data import *
from utils import *
def __init__():
print(StringUtil.substringRight("Hello world!", "l"))
loader = DataLoader("C:/SOME/PATH/")
data/_init_.py
from .data import *
data/data_loader.py
from util.stringUtils import StringUtil
class DataLoader()
def __init__(self, path):
StringUtil.printHierarchyTree(path)
util/_init_.py
from .util import *
util/stringUtil
class StringUtil:
@staticmethod
def substringRight():
...
I just want to load all modules and classes upon start of the app.
It says:
File "main.py", line 5, in <module>
StringUtil.substringRight
NameError: name 'StringUtil' is not defined
also the Data Loader doesnt know StringUtil class