当前模块相对路径和导入
current的Python项目详细描述
获取文件相对于当前模块的路径。导入python模块 相对于当前模块。临时更改导入的sys.path。 获取文件相对于当前调用方的模块的路径。
链接
用法
获取相对于当前模块的路径:
>>>importcurrent>>>here=current.current_path()>>>parent=current.current_path('..')>>>bruces=current.current_path('..','australia','bruces','bruces.ini')
临时将父目录添加到sys.path:
>>>withcurrent.inserted_path()...importaustralia
获取与当前代码的调用方的模块相关的路径:
>>>caller=current.caller_path()>>>callercaller=current.caller_path(steps=2)
更改日志
版本0.3.5:放弃Python3.4支持。
版本0.3.4:标记Python3.7支持。
版本0.3.3:放弃Python3.3支持。添加python_所需。
版本0.3.2:从nose/unittest到pytest的端口测试。更新元数据,标记python 3.5/3.6支持。
版本0.3.1:添加了控制盘。
版本0.3:添加了Python3.3+支持。
版本0.2.1:固定的调用方路径。文件系统获取框架依赖。
版本0.2:添加了调用方路径。
版本0.1:首次公开发布。