Pry and IPython
I found this blog post about IPython and Pry very interesting, since I'm coming at Ruby/Pry from Python/IPython. So, I'm the other way around!
Reproducing their table (with some slight modifications to the IPython column):
| I want to | In Pry | In IPython |
|---|---|---|
| Embed a REPL in a program | binding.pry |
IPython.embed() |
| Show the call stack | show-stack |
import traceback; traceback.print_stack() |
| Run a shell command | .ls $HOME |
!ls $HOME |
| Show methods and variables | ls |
dir(), whos, who, locals(), or globals()
|
| Exit the current REPL | exit |
exit, exit(), quit()
|
| Kill the process | exit-program |
import os; os._exit(0) |
Show foo’s documentation |
? foo |
foo? |
Show foo’s source |
$ foo |
foo?? |
Inspect foo
|
cd foo; ls |
dir(foo) |
Edited by Mike Lockhart | GitLab