我有一个Python的配置文件。有人建议我使用类。所以我有很多这样的常数:
class Paths:
class Sources:
strategylab = 'src/strategylab/'
class Projects:
home = 'prj/'
os.makedirs(home, exist_ok=True)
scenarios_outputs = 'outputs/'
scenarios = 'scenarios/'
datasets = 'datasets/'
# to be configured dinamically
project_path = None
project_single_scenario_path = None
project_single_scenario_output_path = None
project_outputs_path = None
project_name = None
project_datasets_path = None
class Workspace:
temp = 'temp/'
ftp = 'ftp/'
# to be configured dinamically
home = None
temp_location = None
ftp_location = None
class Template:
home = 'model/'
# to be configured dinamically
single_project_template_location = None
如果我在ENUM中转换它们,我应该有什么优势?我还能以平日的方式增加价值吗
编辑:相关的问题没有回答我的疑问,因为我搜索的不是一般用例,而是相对于使用简单类的优势
Enum
是常量,硬盘驱动器上的路径感觉不太恒定:枚举的设计不允许在创建后添加值
相关问题 更多 >
编程相关推荐