First time here? Check out the FAQ!
1

debug iterator

Hello I would like to be able see in the stack data internal variables of an iterator.How can I get the generator expression and the list iterator displaid in the wathcing tool and be updated at each step. at the first step I get this information But when I do a step over the current statement, the watch window is not updated.I get onlythe information gi_running and gi_frame I thnak you for your help

piscvau's avatar
486
piscvau
asked 2019-06-20 09:36:25 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

0

The variable element does not exist until you start to run the iterator and never exists in the context you stopped at in the above screenshot (this is a result of how they are implemented in Python). If you step over the line you are on in the above screenshot, it should arrive at the breakpoint again and from there you can step through the loop using Step Into. Stepping is a bit confusing in this case in that the first time you arrive there the variable also hasn't been defined yet because in Python's implementation of iters you are just before the start of the loop, but element will be defined if you keep stepping. Use Step Into to stay on the line where you have the breakpoint, rather than completing the iteration in one step with Step Over.

Wingware Support's avatar
4k
Wingware Support
answered 2019-06-20 13:39:36 -0500
edit flag offensive 0 remove flag delete link

Comments

Thank this helps. One more detail. When I step into, the line 3 (c =) is either in color or underlined in color. Does the underlining mean that it is the end of an iteration?

piscvau's avatar piscvau (2019-06-21 01:57:27 -0500) edit

Underlining is used when the debugger is on a RETURN event, so yes I think it means it's at the end of the iterator. The behavior of stepping on lines like this is controlled by how Python implements iterators and similar constructs internally and can be a bit odd. If you're working on something more complex that really needs to be stepped through, writing a generator function is probably a better idea. Then step through the generator function and not the iterator.

Wingware Support's avatar Wingware Support (2019-06-21 07:13:35 -0500) edit
add a comment see more comments

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss.

Add Answer