how to iterate over sequence and non-sequence ?
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Oct 20 01:05:16 EDT 2007
On Fri, 19 Oct 2007 18:38:06 +0200, stef mientki wrote:
> I don't have pointers, I've just names (at least I think). Let me
> explain a little bit more,
> I want to simulate / debug a user program, the user program might look
> like this:
>
> x = 5
> for i in xrange(10):
> x = x + 1
I thought you were writing a JAL interpreter:
http://en.wikipedia.org/wiki/JAL_(compiler)
but the code above is Python.
> So now I want to follow the changes in "x" and "i", therefor in the
> background I change the user program a little bit, like this
>
> def user_program():
> x = 5 ; _debug(2)
> global x,i
> _debug (3)
> for i in xrange(10):
> _debug (3)
> x = x + 1 ; _debug (4)
>
> And this modified user program is now called by the main program. Now in
> the _debug procedure I can set breakpoints and watch x and i.
Python already has a debugger. Try this:
import pdb
help(pdb)
--
Steven.
More information about the Python-list
mailing list