[Tutor] Scrolling through output in shell
alan.gauld at btinternet.com
Sun Nov 16 23:28:07 CET 2008
"Mike Hoy" <mhoy06 at gmail.com> wrote
> I'm writing a small program that writes to a text file. I want to be
> able to view the contents of the text file inside of shell. But the
> file is too large for a small shell window.
Can you explain a bity more about what you are doing?
Which shell are you talking about? Are you using IDLE
or some other IDE? Or is it the Unix shell?
> Is there a way for the user to 'scroll' through the contents
> of file that has been read into the program?
Only if you provide a window for the output to be displayed
within. Are you writing a GUI? Or are you using the console
for output? If the latter you can build a paging facility to
display the file a page at a time.
> I noticed that on the man pages that you can do that
> although I'm sure it's not written in python.
Which man pages? How are you viewing them?
> Do I need to find a new language to write this in?
> Maybe use a different language for the output
> and still use python? Any help appreciated.
No you can do anything like this in Python, but I suspect
you may be confused about the difference between Python
the language and the Python interactive prompt. The >>>
prompt is not where you write programs, it is only for
experimenting to find out how features work, or for
testing modules. If you want to write a program you should
do so as a separate file (perhaps using IDLEs File-New menu)
and run it once finished) outside of IDLE.
But I may be misunderstanding things. Can you answer the
questions above to clarify exactly what you are doing?
Author of the Learn to Program web site
More information about the Tutor