[IPython-dev] Changing functions in a running program?
andreas at yank.to
Mon Jan 14 10:16:53 EST 2019
> If you define a function or variable at the breakpoint, it's probably making it a local variable inside main(), so it's not in scope for name().
> You may be able to get round this by defining the new function and then explicitly making it a global variable, something like this:
> globals()['print_name'] = print_name
> Not exactly elegant, but hopefully it works.
Yes—makes sense and does the trick! I’ll have to figure out an Emacs hook to automatically update globals in that manner. My output:
12 import ipdb; ipdb.set_trace()
---> 13 name()
ipdb> !def print_name(): print ("Bob")
ipdb> globals()['print_name'] = print_name
To follow up on Wes’s comment regarding TDD—I’m writing signal processing code and using Python + SciPy like Matlab. There are some calculations when the code starts that take a few minutes. I have a breakpoint there and am experimenting with the next steps of the processing chain.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the IPython-dev