7
votes

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.

1
IPython.core.page.page(my_string) :-) - Thomas K
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
I don't think there's anything built in to IPython to do that, but you can mess with our displayhook implementation. github.com/ipython/ipython/blob/master/IPython/core/… - Thomas K
See stackoverflow.com/questions/5740835/how-to-use-pipe-in-ipython. This is exactly what I was looking for. - Reece

1 Answers

10
votes

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