Jan-17-2023, 06:50 PM
(This post was last modified: Jan-17-2023, 06:50 PM by deanhystad.)
I was able to make your "problem" occur using the code below.
Weird. I guess the lesson is don't get too hung up on how things look. I would not want to guess how many posts on this forum come down to your IDE not behaving how you expect. "I want to print my enormous table, but my program only prints out the first 5 and last 5 rows.columns." "I have a raw string with backslashes, but when I print it out I have double backslashes." "My debugger steps to the line following an if statement even if the if statement is false." Before getting too wound up, verify that what you see is real. Run your program outside the IDE and see if it only prints part of your big table. Check the length of your string to verify that the double backslashes are real. Verify that the debugger executes, or doesn't execute, that command that it shouldn't because the if condition was false.
def func(): for i in range(3): if i == 0: print("hi") print("lo") func()Run the code in the debugger. Set a breakpoint on line 2. Run the program and begin single stepping. The first time through the loop the program prints "hi" and "lo". The second time though the loop the command cursor steps to line 5 instead of jumping from line 3 to line 2. However, the program does not print. This appears to be some kind of debugger artifact. The command cursor always advances to a command following an if statement. When the if statement is at the end of a loop, the command cursor steps to the last command in the if statement body, even if the condition is not true.
Weird. I guess the lesson is don't get too hung up on how things look. I would not want to guess how many posts on this forum come down to your IDE not behaving how you expect. "I want to print my enormous table, but my program only prints out the first 5 and last 5 rows.columns." "I have a raw string with backslashes, but when I print it out I have double backslashes." "My debugger steps to the line following an if statement even if the if statement is false." Before getting too wound up, verify that what you see is real. Run your program outside the IDE and see if it only prints part of your big table. Check the length of your string to verify that the double backslashes are real. Verify that the debugger executes, or doesn't execute, that command that it shouldn't because the if condition was false.