Goal : While being in pdb, I have a "for" loop which runs 1000 ("x" which is not constant) times. I want to skip past 565 iterations of this loop, but look at the 566th ("y" which is not constant) iteration of this loop alone.
The main issue is "y" : the iteration I want to look at is not constant, it can be anything based on previous part of the code, therefore I cannot have an "if" statement inside "for" loop to check which iteration it is and use pdb.set_trace() inside the "if" loop.
code to give some perspective:
def process_queries(input_tuple):
queries, n = input_tuple
result = []
phoneBook = phone_book(n*2)
for cur_query in queries:
if cur_query.type == 'add':
phoneBook.add_number(phoneBook.current_linked_list, cur_query.number, cur_query.name)
elif cur_query.type == 'del':
phoneBook.del_number(phoneBook.current_linked_list, cur_query.number)
else:
response = phoneBook.find_number(phoneBook.current_linked_list, cur_query.number)
result.append(response)
return result
queries
is a list which is of length x
.
process_queries
function is called by another function "function1".
Based on the logic in "function1", the iteration of "for" loop in for cur_query in queries
I might want to stop is different each time and decided on the fly when I'm already in pdb. Therefore, I can't use this:
for index, cur_query in enumerate(queries):
if index == 566:
pdb.set_trace()