Based on this code and the previous __init__.py i did. [[1. The best, but unsafe init.py I made]]
__init__.py
import os
import importlib
import importlib.util
#Get directory containing this file
dir_absolut_path = __file__.replace("\\__init__.py","")
#Get list of all files and folders
file_list = os.listdir(dir_absolut_path)
#Add folders to path
folder_names_list = list()
for folder_name in file_list:
path = dir_absolut_path + "\\" + folder_name
if os.path.isdir(path) and folder_name != "__pycache__":
try:
module = importlib.import_module(f"{__name__}.{folder_name}")
except TypeError:
pass
#Add files.py to path
selected_files_list = list()
for file_name in file_list:
if file_name[-3:] == ".py" and file_name != "__init__.py":
path = dir_absolut_path + "\\" + file_name
spec = importlib.util.spec_from_file_location(file_name, path)
foo = importlib.util.module_from_spec(spec)
spec.loader.exec_module(foo)
file_name = file_name.replace(".py","")
function = getattr(foo, file_name)
globals()[file_name] = function