python - how to import py file from different upper folder? -


all,

file structure:

\ util   utils.py modules   __init__.py   modules1.py   submodule      __init__.py      submodule.py 

i want know how import utils.py in

__init__.py  

for example, run python interpreter in \ level, run import modules, suppose code from ..util.utils import * may works, not.

may know mistake? , may know if there's way can import utils.py in universal format?

import \util\utils.py 

i know may use path.append(), alternative?

thanks

============

got answer post:

import module relative path

if developping python package (what doing, have init.py), simple way import module via package. example, if package called mypackage, then:

import mypackage.utils 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -