开发者

python relative inclusion

开发者 https://www.devze.com 2023-02-06 15:03 出处:网络
I have created a little framework and my directory structure is this myframework -> contrib -> jinja2

I have created a little framework and my directory structure is this

myframework -> contrib -> jinja2
myframework -> contrib -> session
myframework -> start.py

the problem is for package under contrib, infact jinjia2 like session have subdirectory and in the __init开发者_如何学运维__.py of jinja2 there're some imports relative to root position so now to make it working, I must put jinja2 package into root dir, there's a way to make working in


You are going to have a hard time if you are going to redesign the structure of package where relative imports are already used. Just use the package in the way it was designed to and for multiple packages, just make sure that they are all in PYTHONPATH. relative imports work best under the following directory structure and reference mechanism. Just make sure that your modules are accessing the files in the similar way.

0

精彩评论

暂无评论...
验证码 换一张
取 消