【发布时间】:2015-06-09 13:34:33
【问题描述】:
从命令行调用顶级 python package 时是否可以执行操作?
例如,我目前的结构是这样的:
MyApp
| - subdir1
| - pyfile.py
| - pyfile.py
| - pyfile.py
| - subdir2
| - subsubdir1
| - pyfile.py
| - pyfile.py
- __init__
- other.py
我可以做所有正常的事情。例如from MyApp.subdir1 import pyfile。
但是,我希望允许用户通过命令行的顶级名称调用应用程序并让它做一些事情
python MyApp [options]
而不是他们必须使用main() func 将其范围限定为特定模块
python /path/to/MyApp/actions/somemodule.py [options]
这有可能吗?
【问题讨论】:
标签: python