title: Handling high number of configuration parameters in python
body: <p>In my Machine Learning project I have a high number of parameters that are loaded from a configuration file, e.g. a YAML file. I wonder, is there any best practice on how to integrate them in the codebase other than a number of 'setup_by_cfg' functions? I was thinking about classmethods, but then the implementation gets coupled to the parameter file which could be problematic?</p>
  <pre class="lang-py prettyprint-override"><code># option A
  # setup_by_cfg.py
  
  def setup_a(cfg):
      return A(a=cfg.a, b=cfg.b)
  
  def setup_b(cfg):
      ...
  </code></pre>
  <pre class="lang-py prettyprint-override"><code># option B
  # coupled in class implementation
  
  class A:
      # ...
      @classmethod
      def from_cfg(cls, cfg):
          return cls(a=cfg.a, b=cfg.b)
  
  
  class B:
      # ...
      @classmethod
      def from_cfg(cls, cfg):
          # ...
  </code></pre>