title: How can I make a python script change itself?
body: <p>How can I make a python script change itself?</p>
  <p>To boil it down, I would like to have a python script (<code>run.py</code>)like this</p>
  <pre><code>a = 0
  b = 1
  print a + b
  # do something here such that the first line of this script reads a = 1
  </code></pre>
  <p>Such that the next time the script is run it would look like</p>
  <pre><code>a = 1
  b = 1
  print a + b
  # do something here such that the first line of this script reads a = 2
  </code></pre>
  <p>Is this in any way possible? The script might use external resources; however, everything should work by just running the one <code>run.py</code>-file.</p>
  <p>EDIT:
  It may not have been clear enough, but the script should update itself, not any other file. Sure, once you allow for a simple configuration file next to the script, this task is trivial.</p>