Jacs Jacs - 2 months ago 7
Python Question

Python 'Object has no attribute'

Code gives the following error:

"'module' Object has no attribute 'checkNone'"

Dir setup:

+main.py
Sorcery
+Check.py


main.py

from Sorcery import Check
check = Check.checkNone(None);


Check.py

class Check:
def checkNone(content):
if content == None:
print("None!")
else:
print("Check!")
return content

Answer

First, rename the Check.py to anything you like, e.g.,jacs.py. Inside jacs.py, change Class Check: def checkNone(content): to Class Check(object): def checkNone(self, content):.
Then, in main.py, begin with

from Sorcery.jacs import Check
output = Check.checkNone(None)