views:

48

answers:

1

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 am I doing wrong?

+1  A: 

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.

taleinat
I can't believe that didn't occur to me. I thought you would place it on a line before the place where you wanted to enter the debugger.
BryanWheelock