How to page output in >>> ?

Nobody nobody at nowhere.com
Thu Aug 13 01:23:10 CEST 2009


On Wed, 12 Aug 2009 21:41:38 +0000, kj wrote:

> How does one tell the python interactive interpreter to run the
> next output to stdout through the default pager?  Basically, I'm
> looking for Python's equivalent of Perl's debugger's "|" prefix,
> as in
> 
>   DB<1> |print $long_output

Something like:

	sys.stdout.flush()
	p = subprocess.Popen([os.environ['PAGER']], stdin = subprocess.PIPE)
	sys.stdout = p.stdin

	...

	sys.stdout.flush()
	sys.stdout = sys.__stdout__
	p.stdin.close()
	p.wait()

but with error and exception handling.

But personally, I'd write the data to the child process explicitly if
that's possible.




More information about the Python-list mailing list