python脚本需要每用户配置来覆盖(重新定义)“默认”分配(例如path = "local/path/"
),这可以通过使用from custom_settings import *
导入自定义模块的属性来完成。我想输出自定义模块正在更改的那些。
在custom_settings
内,可以使用dir()
获取其属性,例如", ".join( (a for a in dir() if not a.startswith("__") ) )
。
如果导入的模块属性绑定到现有命名空间,如何从导入脚本完成?
答案 0 :(得分:0)
这可能不是最好的解决方案,看起来很痛苦,但你可以随时简单地说:
from custom_settings import *
import custom_settings
overridden = ", ".join(a for a in dir(custom_settings) if not a.startswith("__"))