serhii.net

In the middle of the desert you can say anything you want

15 Dec 2021

IPython

Stumbled yet again1 on mentions of IPython and decided to look into it, prev. assumption being that it’s the same or almost the same thing as Jupyter Notebook. (Also the i in ipdb stands for IPython-enabled, apparently).

It’s not., it’s a separate interactive superset of the Python cli that’s runnable by itself through python3 -m IPython.

Which in turn feels like a better / more interactive shell that can also do magic commands (%xxx) that I’ve seen in Google Colab / Jupyter; additionally understands bash stuff as-is and does other cool stuff. Definitely worth looking into.

ALSO the same article1 mentions a way of using IPython inside ipdb, quoting:

ipdb> from IPython import embed
ipdb> embed() # drop into an IPython session.
        # Any variables you define or modify here
        # will not affect program execution

To run a program with ipdb without editing the source and dropping in an ipdb prompt when if it breaks from shell:

python3 -m ipdb script.py

Took another look at the official docu 26.2. pdb — The Python Debugger — Python 2.7.18 documentation:

  • p prints the expression following, pp pretty-prints it.
Nel mezzo del deserto posso dire tutto quello che voglio.