Ask Your Question

debug iterator

asked 2019-06-20 09:36:25 -0500

piscvau's avatar

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

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-06-20 13:39:36 -0500

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.

edit flag offensive delete link more


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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-06-20 09:36:25 -0500

Seen: 1,037 times

Last updated: Jun 20 '19