title: How do I change a value while debugging python with pdb?
body: <p>I want to run pdb, step through the code, and at some point change the value pointed at by some name.   So I might want to change the value pointed at by the name 'stationLat'.   But it seems I can't. Here's the example:</p>
  
  <pre><code>&gt;&gt;&gt; import extractPercentiles
  &gt;&gt;&gt; import pdb
  &gt;&gt;&gt; pdb.run( "extractPercentiles.extractOneStation()" )
  &gt; &lt;string&gt;(1)&lt;module&gt;()-&gt;None
  (Pdb) s
  --Call--
  &gt; /scratch/extractPercentiles.py(96)extractOneStation()
  -&gt; def extractOneStation() :
  (Pdb) tbreak 132
  Breakpoint 3 at /scratch/extractPercentiles.py:132
  (Pdb) c
  
  Deleted breakpoint 3
  &gt; /scratch/extractPercentiles.py(132)extractOneStation()
  -&gt; stationLon = float(stationLoc[3])
  </code></pre>
  
  <p>So now I'm at a place where I would like to change the value of stationlat.  Pdb appears to allow me to set stationLat to a new value, but when I inspect the value, it is unchanged:</p>
  
  <pre><code>(Pdb) stationLat
  -34.171100000000003
  (Pdb) stationLat = -40
  (Pdb) stationLat   
  -34.171100000000003
  (Pdb) !stationLat = -40
  (Pdb) stationLat
  -34.171100000000003
  (Pdb) 
  </code></pre>
  
  <p>You can see I tried using ! as well, without success.</p>
  
  <p>The pdb manual says I should be able to change variables:</p>
  
  <p><em>Commands that the debugger doesn’t recognize are assumed to be Python statements and are executed in the context of the program being debugged. Python statements can also be prefixed with an exclamation point (!). This is a powerful way to inspect the program being debugged; <strong>it is even possible to change a variable</em></strong> or call a function</p>
  
  <p>Is this a question of scope?  Is it to do with the way I have started pdb?  I tried the embedded "pdb.set_trace" idiom and I got the same result.  </p>
  
  <p>Thanks for reading.</p>