Python ImportError: No module named 'path' -
''' data class''' import os.path random import random class testdata(object, random): def fetchdatafromfile(self, filename): """ open file read """ myfile = open(os.path.join(os.getcwd(),filename), 'r') """ read information in file """ lines = myfile.read() ''' remove header not used ''' header = lines[0] lines.remove(header) return lines
i getting:
importerror: no module named path
file "pyclasspath/lib/testdata.py", line 2, in
os.path working in other classes in project. can point me mistake doing?
i moved file 1 directory another. apart it, there no difference between class , other classes.
import os
should work fine instead
import os random import random class testdata(object, random): def fetchdatafromfile(self, filename): """ open file read """ myfile = open(os.path.join(os.getcwd(),filename), 'r') """ read information in file """ lines = myfile.read() ''' remove header not used ''' header = lines[0] lines.remove(header) return lines
as asside method be
def fetchdatafromfile(self, filename): """ open file read """ return list(open(os.path.join(os.getcwd(),filename), 'r'))[1:]
Comments
Post a Comment