How to page output in >>> ?

K

kj

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

TIA!

kynn
 
N

Nobody

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.
 
G

Gabriel Genellina

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

Try using pydoc.pager - read the source
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top