From: Ben Finney on
John Machin <sjmachin(a)lexicon.net> writes:

> C:\junk>python demomore.py | more

Your example uses the OS shell to invoke a pager on the output of the
Python process. The OP was asking about paging *within* the Python
shell.

To my knowledge there's nothing in the default Python shell that
enables what the OP is asking for. There are other Python shells, e.g.
Idle, ipython, or a Python window inside Emacs, that may be better
suited.

--
\ "Compulsory unification of opinion achieves only the unanimity |
`\ of the graveyard." -- Justice Roberts in 319 U.S. 624 (1943) |
_o__) |
Ben Finney
From: Alex K on
Thanks it's good to know. iPyton looks really neat.

On 15/01/2008, Ben Finney <bignose+hates-spam(a)benfinney.id.au> wrote:
> John Machin <sjmachin(a)lexicon.net> writes:
>
> > C:\junk>python demomore.py | more
>
> Your example uses the OS shell to invoke a pager on the output of the
> Python process. The OP was asking about paging *within* the Python
> shell.
>
> To my knowledge there's nothing in the default Python shell that
> enables what the OP is asking for. There are other Python shells, e.g.
> Idle, ipython, or a Python window inside Emacs, that may be better
> suited.
>
> --
> \ "Compulsory unification of opinion achieves only the unanimity |
> `\ of the graveyard." -- Justice Roberts in 319 U.S. 624 (1943) |
> _o__) |
> Ben Finney
> --
> http://mail.python.org/mailman/listinfo/python-list
>
From: Gabriel Genellina on
En Mon, 14 Jan 2008 21:05:38 -0200, Ben Finney
<bignose+hates-spam(a)benfinney.id.au> escribi�:

> To my knowledge there's nothing in the default Python shell that
> enables what the OP is asking for. There are other Python shells, e.g.
> Idle, ipython, or a Python window inside Emacs, that may be better
> suited.

Yes, there is. Thanks to Tim Roberts who menctioned that the builtin help
system implements paging internally, I looked at it. It's easy to use (but
maybe too late for the OP):

Let Python determine the best pager available:

import pydoc
pydoc.pager(text)

(it may pipe the text into an external program like less or more). Or
explicitely use the builtin pager:

import pydoc
pydoc.ttypager(text)


--
Gabriel Genellina

From: gagsl-py2 on

--- Alex K <spaceoutlet(a)gmail.com> escribi�:

> Thank you for this interesting tip. However I'm not
> sure to know how
> to use it. It seems pydoc.pager('text') just pages
> the text passed in.
> How do I actually make the python shell use a
> different pager?

I'm unsure of what you want. Do you want the print
statement, inside the Python interpreter, to page its
output? Write a function to page the output the way
you like, and assign it to sys.displayhook (see
http://docs.python.org/lib/module-sys.html#l2h-5124 )

--
Gabriel Genellina


Tarjeta de cr�dito Yahoo! de Banco Supervielle.
Solicit� tu nueva Tarjeta de cr�dito. De tu PC directo a tu casa. www.tuprimeratarjeta.com.ar
From: Alex K on
That seems interesting but it's not quite what I want to do. To take
an example I would like to be able to do something similar to the
mysql shell when its pager is set to less. Displayhook is called
whenever an expression is being evaluated. I'd like to call 'less' on
the ouput of a statement.

Alex

On 26/01/2008, gagsl-py2(a)yahoo.com.ar <gagsl-py2(a)yahoo.com.ar> wrote:
>
> --- Alex K <spaceoutlet(a)gmail.com> escribió:
>
> > Thank you for this interesting tip. However I'm not
> > sure to know how
> > to use it. It seems pydoc.pager('text') just pages
> > the text passed in.
> > How do I actually make the python shell use a
> > different pager?
>
> I'm unsure of what you want. Do you want the print
> statement, inside the Python interpreter, to page its
> output? Write a function to page the output the way
> you like, and assign it to sys.displayhook (see
> http://docs.python.org/lib/module-sys.html#l2h-5124 )
>
> --
> Gabriel Genellina
>
>
> Tarjeta de crédito Yahoo! de Banco Supervielle.
> Solicitá tu nueva Tarjeta de crédito. De tu PC directo a tu casa. www..tuprimeratarjeta.com.ar
> --
> http://mail.python.org/mailman/listinfo/python-list
>