8

I often need to view long text variables in iPython. I typically use scroll buffers for this, but I really want a pager with searching. Does iPython have a way to view long variables in a pager (e.g., less)? If not, I can certainly contrive a way to do this with !.

Note: I'm not asking how to set up PAGER generally. ?, ??, %pdoc, etc all work fine with a less. I'm asking specifically for paging variables.

Reece
  • 7,616
  • 4
  • 30
  • 46
  • 2
    `IPython.core.page.page(my_string)` :-) – Thomas K Dec 05 '12 at 13:26
  • That's good. I can at least wrap that as a customized function. Do you know of a way to have that invoked by default when displaying a variable? Something like this: `In [1]: import httplib2 In [2]: resp,data = httplib2.Http().request('http://google.com') In [3]: data ` – Reece Dec 06 '12 at 17:06
  • I don't think there's anything built in to IPython to do that, but you can mess with our displayhook implementation. https://github.com/ipython/ipython/blob/master/IPython/core/displayhook.py – Thomas K Dec 06 '12 at 23:19
  • See http://stackoverflow.com/questions/5740835/how-to-use-pipe-in-ipython. This is exactly what I was looking for. – Reece Jan 08 '13 at 11:48

1 Answers1

10

Answer: %page

Example usage:

snafu$ ipython
In [1]: import httplib2
In [2]: resp,data = httplib2.Http().request('http://google.com')
In [3]: %page data

Answer from How to use Pipe in ipython

Community
  • 1
  • 1
Reece
  • 7,616
  • 4
  • 30
  • 46