I’m trying to call a function from a file(addonstest.py, function is commands(inp)), it returns an attribute error
In the main file(lot of indents as in both an elif and a while loop, not shown here)
cat = []
a = 0
for i in modmetas:
cat.append(i["id"])
sys.path.insert(1,str(mods[a]) + "/code")
try:
__import__(("addons" + i["id"]))
except:
print(str(i) + la["nocom"])
a +=1
(types.ModuleType("addons" + i["id"])).commands(incom)
In the file addonstest.py
def commands(inp):
if inp == "//test":
print("Test success")
Context: la is a json variable for localisation, modmetas is another json for info(id in the modmetas is “test”)
I tried to move the __import__
, but it didn’t do anything. There are no errors importing and the addonstest.py works perfectly fine on its own. It’s supposed to run the function in the main file.
LTIT is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.