(text, cmd)
Page through text by invoking a program on a temporary file.
Page through text by invoking a program on a temporary file.
Page through text by invoking a program on a temporary file .
def tempfilepager(text, cmd):
    """Page through text by invoking a program on a temporary file."""
    import tempfile
    with tempfile.TemporaryDirectory() as tempdir:
        filename = os.path.join(tempdir, 'pydoc.out')
        with open(filename, 'w', errors='backslashreplace',
                  encoding=os.device_encoding(0) if
                  sys.platform == 'win32' else None
                  ) as file:
            file.write(text)
        os.system(cmd + ' "' + filename + '"')
def tempfilepager ( text , cmd ) : import tempfile with tempfile . TemporaryDirectory ( ) as tempdir : filename = os . path . join ( tempdir , 'pydoc.out' ) with open ( filename , 'w' , errors = 'backslashreplace' , encoding = os . device_encoding ( 0 ) if sys . platform == 'win32' else None ) as file : file . write ( text ) os . system ( cmd + ' "' + filename + '"' )