[IPython-dev] IPython-dev Digest, Vol 174, Issue 2

Andreas Yankopolus andreas at yank.to
Sat Jan 12 20:56:54 EST 2019


> https://stackoverflow.com/questions/48112226/update-a-function-during-debugging-pdb-or-ipdb
> - Does this work from just a plain ipdb shell (when not sending the new function definition from emacs)?

This is getting close, but updating the function as proposed doesn’t work. Using the example code from my previous post:

ayank at snorri:~/Documents$ ./foo.py 
In main.
> /home/ayank/Documents/foo.py(16)main()
     14     print ("In main.")
     15     Pdb().set_trace()
---> 16     name()
     18 if __name__ == "__main__":

ipdb> print_name()
ipdb> name()
ipdb> !def print_name(): print ("Bob")
ipdb> print_name()
ipdb> name()

We can see that the function is updated, but functions that call it do not get updated to use the new definition. Any idea what’s going on here?

This kind of thing is no problem in Lisp, but its macro facility means that support for changing code at runtime is baked deep into the language. Perhaps there’s something missed in the IPython REPL?



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20190112/c58cb6ad/attachment.html>

More information about the IPython-dev mailing list