title: What is the proper way of writing a global config file?
body: <p>I need to write a config file so that any other .py files with this config imported will be able to access the variables inside it.</p>
  
  <p>Now I also want to modify some of those variables in a main.py according to the input parameters of argparse. However, I don't know how to make the modification also work for other files.</p>
  
  <p>For example, in <code>config.py</code>:</p>
  
  <pre class="lang-py prettyprint-override"><code>VariableA = 5
  </code></pre>
  
  <p>in <code>func.py</code>:</p>
  
  <pre class="lang-py prettyprint-override"><code>import config
  
  def display():
      print(config.VariableA)
  </code></pre>
  
  <p>in <code>main.py</code>:</p>
  
  <pre class="lang-py prettyprint-override"><code>import config
  from func import display
  config.VariableA = 10
  display()  # 5
  </code></pre>
  
  <p>The output will be <code>5</code> instead of 10. How could I modify the variables in config.py so that it works for the rest of scripts?</p>
  
  <p>I tried to define a class and set the variables to be the static variables of this class, such as:</p>
  
  <pre class="lang-py prettyprint-override"><code>class Config:
      VariableA = 5
  
  Config.VariableA = 10
  </code></pre>
  
  <p>and this did work. But I don't know if this solution is the most proper way?</p>