Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > paging in python shell

Reply
Thread Tools

paging in python shell

 
 
Alex K
Guest
Posts: n/a
 
      01-12-2008
Hello,

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

Alex
 
Reply With Quote
 
 
 
 
Tim Roberts
Guest
Posts: n/a
 
      01-13-2008
"Alex K" <> 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,
Providenza & Boekelheide, Inc.
 
Reply With Quote
 
 
 
 
Alex K
Guest
Posts: n/a
 
      01-14-2008
Hi Tim,

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

Alex

On 14/01/2008, Tim Roberts <> wrote:
> "Alex K" <> 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,
> Providenza & Boekelheide, Inc.
> --
> http://mail.python.org/mailman/listinfo/python-list
>

 
Reply With Quote
 
John Machin
Guest
Posts: n/a
 
      01-14-2008
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 --


 
Reply With Quote
 
Alex K
Guest
Posts: n/a
 
      01-14-2008
Thanks John, but would it be possible to remain in the python interpreter?

On 14/01/2008, John Machin <> 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/python-list
>

 
Reply With Quote
 
Ben Finney
Guest
Posts: n/a
 
      01-14-2008
John Machin <> 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
 
Reply With Quote
 
Alex K
Guest
Posts: n/a
 
      01-15-2008
Thanks it's good to know. iPyton looks really neat.

On 15/01/2008, Ben Finney <bignose+hates-> wrote:
> John Machin <> 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
>

 
Reply With Quote
 
Gabriel Genellina
Guest
Posts: n/a
 
      01-21-2008
En Mon, 14 Jan 2008 21:05:38 -0200, Ben Finney
<bignose+hates-> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How to pass shell variable to shell script from python D'Arcy J.M. Cain Python 0 02-27-2008 12:56 PM
Re: How to pass shell variable to shell script from python Gerardo Herzig Python 1 02-27-2008 11:19 AM
Re: paging in python shell Gabriel Genellina Python 0 01-27-2008 05:28 AM
Re: paging in python shell Alex K Python 0 01-26-2008 09:26 AM
Re: paging in python shell Python 0 01-25-2008 10:00 PM



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57