[Tutor] cartesian product recursive loop
Kent Johnson
kent37 at tds.net
Wed Jul 19 00:02:32 CEST 2006
Gabriel Farrell wrote:
>> > Each call to rloop() has its own local variables and its own state.
>> > Returning from one call doesn't pop all the way up the stack, it
>> > resumes execution at the point of call with the local state restored
>> > to what it was before the call.
>>
>
> Okay, this was the main abstraction I was missing, and you've spelled
> it out clearly. It seems like such an "intelligent" way to handle the
> flow -- I think that's what threw me off.
>
This is typical behavior for many languages, not special to Python.
Generally each invocation of a function will have its own stack frame.
> I read
> http://www.ferg.org/papers/debugging_in_python.html , imported pdb,
> and inserted pdb.set_trace() after
>
> def rloop(seqin, listout, comb):
>
> I'm seeing now, by stepping through the program, how it flows. Pdb is
> pretty awesome! I had a feeling there was something like different
> levels of loops going on, but I didn't get it before.
>
Impressive that you picked up pdb so easily. You might be interested in
a debugger with a GUI, there are several for Python. A primitive one is
part of IDLE. I like winpdb. Other dev tools have Python debugger
support as well.
> Thanks, Kent!
You're welcome, it's very gratifying to see the light go on like this :-)
Kent
More information about the Tutor
mailing list