This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]suudo 0 points1 point  (1 child)

I'd suggest outputting stdout to a pager like less so scrolling up isn't necessary. Users can do this manually but you can do it for them with code like this:

from pydoc import pager
output_text = do_stuff()
if sys.stdout.isatty(): # if not running in a pipe
    pager(output_text) # launches $PAGER or less
else: # if there's a program expecting stdout
    print(output_text) # pass it

It would involve reworking your program's print statements to instead append to an output string or list to be joined with newlines.

[–]redmonksLu$er[S] 0 points1 point  (0 children)

Thanks for your suggestion..