Question about %psource in notebook

#1

Hi all. In the not-too-distant past %psource would display source code as the output of a cell. Now it pops up a window. Is there any way to get the old behavior back?

I can use the inspect module to get the source code and print it myself, but I don’t get syntax highlighting.

Thanks!
Allen

1 Like
#2

@AllenDowney Yeah, you can set the IPython pager to print. Add the following lines to the beginning of your notebook.

from IPython.core import page
page.page = print

Then try %psource.

Is this what you were looking for?