class DefaultConfig(object):
class S3(object):
DATA_ROOT = 's3://%(bucket_name)s/NAS'
DATA_LOCATION = '{}/%(instrument_id)s/%(run_id)s'.format(DefaultConfig.S3.DATA_ROOT)
上面的代碼給了我下面的錯誤。python默認配置重用變量
File "./s3Utils.py", line 5, in <module>
from InfraConfig import InfraConfig as IC
File "/opt/src/datasource/src/main/python/util/InfraConfig.py", line 4, in <module>
class DefaultConfig(object):
File "/opt/src/datasource/src/main/python/util/InfraConfig.py", line 6, in DefaultConfig
class S3(object):
File "/opt/src/datasource/src/main/python/util/InfraConfig.py", line 14, in S3
DATA_LOCATION = '{}/%(instrument_id)s/%(run_id)s'.format(DefaultConfig.S3.DATA_ROOT)
NameError: name 'DefaultConfig' is not defined
爲什麼找不到DefaultConfig.S3.DATA_ROOT 此外,這是我在寫作的結構化配置與DefaultConfig值的重用嘗試。有沒有辦法做到這一點,而不寫一個XML文件?
@ŁukaszRogalski:這實際上是一個MCVE。 – user2357112
@ user2357112是的,我誤解並曲解了這個問題 –