[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

paging in python shell

Alex K

1/12/2008 9:46:00 AM

Hello,

Does anyone know if the python shell supports paging or if I should
look into iPython? Thank you so much.

Alex
7 Answers

Tim Roberts

1/13/2008 11:37:00 PM

0

"Alex K" <spaceoutlet@gmail.com> wrote:
>
>Does anyone know if the python shell supports paging or if I should
>look into iPython? Thank you so much.

"Paging" is an overloaded term. What do you mean, exactly? Do you mean
something like piping the output into "more"? The Python shell does that
for the "help" command, but maybe you could post a more precise example of
what you want.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Alex K

1/14/2008 8:35:00 PM

0

Hi Tim,

Yes I mean piping the output into "more" for example.

Alex

On 14/01/2008, Tim Roberts <timr@probo.com> wrote:
> "Alex K" <spaceoutlet@gmail.com> wrote:
> >
> >Does anyone know if the python shell supports paging or if I should
> >look into iPython? Thank you so much.
>
> "Paging" is an overloaded term. What do you mean, exactly? Do you mean
> something like piping the output into "more"? The Python shell does that
> for the "help" command, but maybe you could post a more precise example of
> what you want.
> --
> Tim Roberts, timr@probo.com
> Providenza & Boekelheide, Inc.
> --
> http://mail.python.org/mailman/listinfo/p...
>

John Machin

1/14/2008 8:49:00 PM

0

On Jan 15, 7:35 am, "Alex K" <spaceout...@gmail.com> wrote:
> Hi Tim,
>
> Yes I mean piping the output into "more" for example.
>

Why don't you "suck it and see"???

E.g.

C:\junk>copy con demomore.py
for i in range(100):
print 'line', i
^Z
1 file(s) copied.

C:\junk>python demomore.py | more
line 0
line 1
line 2
line 3
line 4
[snip]
line 50
line 51
line 52
line 53
line 54
line 55
line 56
-- More --


Alex K

1/14/2008 9:02:00 PM

0

Thanks John, but would it be possible to remain in the python interpreter?

On 14/01/2008, John Machin <sjmachin@lexicon.net> wrote:
> On Jan 15, 7:35 am, "Alex K" <spaceout...@gmail.com> wrote:
> > Hi Tim,
> >
> > Yes I mean piping the output into "more" for example.
> >
>
> Why don't you "suck it and see"???
>
> E.g.
>
> C:\junk>copy con demomore.py
> for i in range(100):
> print 'line', i
> ^Z
> 1 file(s) copied.
>
> C:\junk>python demomore.py | more
> line 0
> line 1
> line 2
> line 3
> line 4
> [snip]
> line 50
> line 51
> line 52
> line 53
> line 54
> line 55
> line 56
> -- More --
>
>
> --
> http://mail.python.org/mailman/listinfo/p...
>

Ben Finney

1/14/2008 11:06:00 PM

0

John Machin <sjmachin@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

Alex K

1/15/2008 6:18:00 AM

0

Thanks it's good to know. iPyton looks really neat.

On 15/01/2008, Ben Finney <bignose+hates-spam@benfinney.id.au> wrote:
> John Machin <sjmachin@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/p...
>

Gabriel Genellina

1/21/2008 6:23:00 AM

0

En Mon, 14 Jan 2008 21:05:38 -0200, Ben Finney
<bignose+hates-spam@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