I have a script that I am currently working on, named exp1.py and it's located in
/project/exp1.py
In this script, I am trying to call a function named computelikelihood(), which is inside the class Class(), which is in script method.py, in a different directory:
/project/methods/c_CLASS/method.py
So, in my code in exp1.py, I do this:
import sys
sys.path.append('/project/methods/c_CLASS/')
Which gets me to the folder where method.py is located, but when I want to call the Class() from the method.py, so that I get the function computelikelihood(), that I actually want, I get error. I try this:
from method import Class
from Class import computelikelihood
But I get ImportError: No module named Class. Can anyone help?
EDIT
This is how the __init__ of my Class looks like:
class Class:
def __init__(self,e2wl,w2el,label_set):
self.e2wl = e2wl
self.w2el = w2el
self.workers = self.w2el.keys()
self.examples = self.e2wl.keys()
self.label_set = label_set
from method.Class import computelikelihoodcomputelikelihoodis a static/class method, you can call it fromClass, e.g.Class.compputelikelihood(...). If it is a method, you'll need to instantiate aClassfirst.computelikelihoodis just a function , but I don't understand what you mean by "static/class method" or "method". Or also by instantiating theClassfirst. Or how to useClass.compputelikelihood()in myexp1.pyscript.computelikelihoodwere just a function, you wouldn't need to referenceClassat all.