0

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?

Edited by ultimatebuster: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by pyTony
0
import sys
sys.path.append("..\\log") #(windows style) path to the module
import log

Edited by jcao219: n/a

0

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'
>>>
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.