How to stop the program when the output fills the screen in python?
Question: How can I get the status of the terminal from a Python program? I want the
program to stop printing lines to the screen when the screen is full and wait
for user input.


Answer: The simplest (no code) way to accomplish that is to pipe your program's output
through a pager program like `less` or `more` (assuming *nix), like:

### infinity.py

    
    
    import random
    
    while 1:
       print random.randint(0, 0xffffffff)
    

### command line

    
    
    python infinty.py | less
    

...gives output like:

    
    
    848605718
    899092472
    2576425641
    3098821373
    259379057
    164782822
    416064876
    2488878735
    1216764788
    2682214542
    531576871
    2175787865
    869960770
    :
    

...and waits for user input.

