title: Updating of a config file written in python
body: <p>I'm writing a simulation software which should support reading parameters from a config file or from the command line. It is very important to be able to track what was the configuration of a simulation, I'm committing the config file to a local git repository at the start of simulation. </p>
  
  <p>Now if I have parameters on the command line they have higher priority than the ones in the config file. But I also want to commit them. I guess I could save the python objects of a configured simulation, just before it is started. But it would be more elegant, if I could just update the config file with the command line parameters before committing it. </p>
  
  <p>The reason I write the config file in python is that I have to define some python objects in it. I have something like </p>
  
  <pre><code>import SomeSimulationClass
  SIMULATOR = SomeSimulationClass
  </code></pre>
  
  <p>in my config file and the SIMULATOR can then be swapped easily.
  If I want to use something like configparser I can't have objects I believe. </p>
  
  <p>Is there any easy way to update a python config file? All variable names in it are already defined, I just want to change the values. The only thing I can think of is parsing the file, comparing strings between the file and the command line parameters ...</p>