Eclipse PyDev 插件包括出色的集成autopep8支持。它会在保存时自动将代码格式化为 PEP8 样式,并带有几个旋钮和选项来根据您的需要进行定制。
但是autopep8导入格式化程序会破坏site.addsitedir()使用。
import site
site.addsitedir('/opt/path/lib/python')
# 'ourlib' is a package in '/opt/path/lib/python', which
# without the above addsitedir() would otherwise not import.
from ourlib import do_stuff
在 PyDev 的autopep8导入格式化程序之后,它将其更改为:
import site
from ourlib import do_stuff
site.addsitedir('/opt/path/lib/python')
与. from ourlib import do_stuff_ImportError: No module named ourlib
问题:
是否有 PyDev 设置或autopep8命令行选项来阻止它移动site.addsitedir()呼叫?