I'm working with my Django app. For some reason an element of a list is being assigned incorrectly.
I'm trying to set a break where I think the error is occurring. ( line 20 )
I'm invoking pdb with this line of code:
import pdb; pdb.set_trace()
However, inside the code, I can't seem to set a Break.
(Pdb) b 20
*** Blank or comment
(Pdb) break 20
*** Blank or comment `
What开发者_JAVA百科 am I doing wrong?
pdb is telling you that line 20 of the file you're in doesn't contain code; it's either blank or just contains a comment. Such a line will never actually be executed, so a breakpoint can't be set on it.
Use the 'list' command to see the code of the file you're currently in ('help list' for details on this command), and then set breakpoints on lines which include executable code.
You can also use the 'where' command to see the stack frame, since you might not be in the right file because you're not looking at the level of the stack frame where you think you are. Use 'up' and 'down' to go to the level of the stack where you want to debug.
精彩评论