python default configuration reuse of variables
<pre><code>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)
</code></pre>

<p>The code above gives me the following error. </p>

<pre><code>      File "./s3Utils.py", line 5, in &lt;module&gt;
    from InfraConfig import InfraConfig as IC
  File "/opt/src/datasource/src/main/python/util/InfraConfig.py", line 4, in &lt;module&gt;
    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
</code></pre>

<p>Why is it unable to find DefaultConfig.S3.DATA_ROOT
Also, this is my attempt at writing structured configuration with reuse of values of DefaultConfig. Is there a way to do this without writing a yml file?</p>

<p>You should use it without any prefixes:</p>

<pre><code>class DefaultConfig(object):
  class S3(object):
    DATA_ROOT = 's3://%(bucket_name)s/NAS'
    DATA_LOCATION = '{}/%(instrument_id)s/%(run_id)s'.format(DATA_ROOT)

 print DefaultConfig.S3.DATA_LOCATION
</code></pre>

<p>returns:</p>

<pre><code>&gt; s3://%(bucket_name)s/NAS/%(instrument_id)s/%(run_id)s
</code></pre>

python