Ipython: is it possible to disable the pager, or to tell specific magics not to use the pager?

Created on 22 Mar 2014  ·  3Comments  ·  Source: ipython/ipython

Hello,
Not sure if you guys handle support questions through the issue tracker or elsewhere, but if elsewhere and you can point me there I'm happy to repost.

I'm trying to get the output of %psource to print following the cell, rather than have the output run through the pager in the HTML Notebook. I've poked around the documentation, did some googling, and poked through the issue tracker (most related issue I found is #1947) and source code, but I'm having a hard time figuring out how to do this. Is it possible? If not, I think that would be a really useful feature.

My specific use case is that I'm putting bioinformatics educational materials together using the Notebook, and want to display source code for some key functions inline, so they display nicely e.g. via nbviewer as features of the source code are discussed in the surrounding text.

Thanks for the help with this!
Greg

Most helpful comment

It's a bit more complex these days, since page() is called with a dict of mime-type-keyed documents. Here's what disabled the pager for my IPython 5.1.0 installation:

In ~/.ipython/profile_default/startup/no-pager.py:

from __future__ import print_function

def page_printer(data, start=0, screen_lines=0, pager_cmd=None):
    if isinstance(data, dict):
        data = data['text/plain']
    print(data)

import IPython.core.page
IPython.core.page.page = page_printer

All 3 comments

Yup, you can just replace the pager call with print: http://nbviewer.ipython.org/gist/minrk/7715212

Worked perfectly, thank you!

It's a bit more complex these days, since page() is called with a dict of mime-type-keyed documents. Here's what disabled the pager for my IPython 5.1.0 installation:

In ~/.ipython/profile_default/startup/no-pager.py:

from __future__ import print_function

def page_printer(data, start=0, screen_lines=0, pager_cmd=None):
    if isinstance(data, dict):
        data = data['text/plain']
    print(data)

import IPython.core.page
IPython.core.page.page = page_printer
Was this page helpful?
0 / 5 - 0 ratings

Related issues

lewisacidic picture lewisacidic  ·  3Comments

jakirkham picture jakirkham  ·  4Comments

sataliulan picture sataliulan  ·  4Comments

ghost picture ghost  ·  4Comments

jwkvam picture jwkvam  ·  4Comments