[Tutor] Scrolling through output in shell

Eike Welk eike.welk at gmx.net
Tue Nov 18 13:53:31 CET 2008

On Monday 17 November 2008, ALAN GAULD wrote:
> > I'm writing a program that reads a text file onto the screen. The
> > text file is too large to read so I want to be able to scroll
> > through it with the arrow key or something like that. I am not
> > using GUI.

You could also output the text, and give it to 'less' to display it. 
This is exactly what 'man' does.
You start other programs from python with the 'subprocess' module:

You could also go the classical Unix way and output the text to 
standard output (just use print). If necessary you could then give 
the output to 'less'. Your program(s) would be used in the following 

my_program --foo -a -b -c --be-cool --read this-file.txt | less

Command line options are parsed with the 'optparse' module:

Kind regards,

More information about the Tutor mailing list