Re: IPython-dev Digest, Vol 174, Issue 2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Re: IPython-dev Digest, Vol 174, Issue 2

Andreas Yankopolus
Wes,

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@snorri:~/Documents$ ./foo.py 
In main.
> /home/ayank/Documents/foo.py(16)main()
     14     print ("In main.")
     15     Pdb().set_trace()
---> 16     name()
     17 
     18 if __name__ == "__main__":

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

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?

Thanks,

Andreas



_______________________________________________
IPython-dev mailing list
[hidden email]
https://mail.python.org/mailman/listinfo/ipython-dev