The directory layout looks like this
base -- +
parcer -- +
parcer.py
log -- +
log.py
I want to import log.py from parcer.py. How would I do that?
The directory layout looks like this
base -- +
parcer -- +
parcer.py
log -- +
log.py
I want to import log.py from parcer.py. How would I do that?
import sys
sys.path.append("..\\log") #(windows style) path to the module
import log
Maybe better to use os.path.join, works also in not-Windows (or should I say Windows' complement :-) )
import sys,os
>>> sys.path.append(os.path.join('..','log'))
>>> sys.path[-1]
'..\\log'
>>>
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.