[IPython-user] Erroneous Pager behavior under Windows XP

TP wingusr@gmail....
Tue Feb 23 05:23:58 CST 2010


  If you are on a system which lacks proper data pagers (such as
  Windows), IPython will use a very limited builtin pager.

This very limited pager for Windows XP doesn't seem to be able to
display previous pages among other things.

Following the instructions just above that statement, I decided to try
defining these environment variables to use the cygwin version of
"less" (where c:/cygwin/bin/ is in my PATH):


This seems to work. "?" now pages thru the basic IPython help info (at
least I can go back to previously displayed pages).

However, the %page magic doesn't correctly calculate the length of
paged output. For example:

    In [14]: lst=dir(__IP)
    In [15]: page lst

doesn't show the very long list lst via the pager?

The reason is the following line of code from the page() method in

    str_lines = strng.split(os.linesep)[start:]

It turns out that some upstream commands that call page() don't join
their lines with os.linesep ("\r\n" on Windows), but rather just use
"\n". So one possible fix is:

    if strng.count("\n") > strng.count(os.linesep):
        str_lines = strng.split("\n")[start:]
        str_lines = strng.split(os.linesep)[start:]

More information about the IPython-user mailing list