python - Set debugger breakpoint at end of a function without return -
i debugging method f()
has no return
in it.
class a(object): def __init__(self): self.x = [] def f(self): in range(10): self.x.append(i)
i need see how method modifies variable x
right after called. that, insert return
@ end of method, , set breakpoint there:
that way, method reaches return
, can see value of variable x
.
this job, pretty sure there better way. editing method or function every time need debug seems silly.
question:
there different way (e.g. option in debugger) set breakpoint @ end of method not have return
?
(note setting breakpoint @ function call , using step over not display x
when mouseovering, since function called different module.)
you can add conditional breakpoint on last line , set condition occurs in last iteration.
in instance condition easy since it's i == 9
, may lot more complex depending on loop condition adding statement @ end easier solution.
that screenshot intellij idea , screenshot looks it's same ide, right-click breakpoint show dialog , enter condition.
if you're using other ide i'm sure there capability make breakpoint conditional.
update:
there no support breaking @ end of method in python debugger, @ start of method:
b(reak) [[filename:]lineno | function[, condition]]
with lineno argument, set break there in current file. function argument, set break @ first executable statement within function. line number may prefixed filename , colon, specify breakpoint in file (probably 1 hasn't been loaded yet). file searched on sys.path. note each breakpoint assigned number other breakpoint commands refer.
if second argument present, expression must evaluate true before breakpoint honored.
without argument, list breaks, including each breakpoint, number of times breakpoint has been hit, current ignore count, , associated condition if any.
Comments
Post a Comment