title: Python time variable is not changing
body: <p>I modified some code I found <a href="https://stackoverflow.com/questions/1557571/how-to-get-time-of-a-python-program-execution/1557906#1557906">here</a> on stackoverflow, but I get some weird behaviour. Can anyone see my error?</p>
  
  <pre><code>import atexit
  from time import clock
  
  line = "="*10 + "&gt;&gt;&gt;"
  
  def secondsToStr(s):
      return "{0}.{1}ms".format(round(s*1000), round(s*1000000))
  
  ##
  # @brief Starts a timer. If the program crashes, the end function will be called anyway.
  def start():
      atexit.register(stop)
      print(line,"Start time measurement")
      startTime = clock()
      print("new start time:", startTime)
  
  ##
  # @brief Needs to be called after start(). Prints the time passed since start() was called.
  def stop():
      end = clock()
      elapsed = end-startTime
      print(startTime, end)    # Inserted for debugging
      print(line, "Ellapsed time:", secondsToStr(elapsed))
      atexit.unregister(stop)
  
  def now():
      return secondsToStr(clock())
  
  startTime = clock()
  </code></pre>
  
  <p>The idea is to call <code>start()</code> and <code>stop()</code> to measure the time the program takes in between those two calles. Weirdly, the <code>startTime</code> does not change. Thus every call of <code>stop()</code> gives the past time since the first call of <code>start()</code>. Here is an example output:</p>
  
  <pre><code>==========&gt;&gt;&gt; Start time measurement
  new start time: 0.285078
  Doing work
  0.231932 1.766478
  ==========&gt;&gt;&gt; Ellapsed time: 1535.1534546ms
  
  ==========&gt;&gt;&gt; Start time measurement
  new start time: 1.766624
  More work
  0.231932 1.975752
  ==========&gt;&gt;&gt; Ellapsed time: 1744.1743820ms
  
  ==========&gt;&gt;&gt; Start time measurement
  new start time: 1.975821
  More work
  0.231932 1.976301
  ==========&gt;&gt;&gt; Ellapsed time: 1744.1744369ms
  </code></pre>
  
  <p>Why is the <code>startTime</code> never changing? It should get a new value every time <code>start()</code> is called.</p>