paging in python shell
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Sun Jan 27 01:28:04 EST 2008
[reformatting to bottom-post]
En Sat, 26 Jan 2008 08:26:37 -0200, Alex K <spaceoutlet at gmail.com>
escribi�:
> On 26/01/2008, gagsl-py2 at yahoo.com.ar <gagsl-py2 at yahoo.com.ar> wrote:
>> --- Alex K <spaceoutlet at gmail.com> escribió:
>>
>> > Thank you for this interesting tip. However I'm not
>> > sure to know how
>> > to use it. It seems pydoc.pager('text') just pages
>> > the text passed in.
>> > How do I actually make the python shell use a
>> > different pager?
>>
>> I'm unsure of what you want. Do you want the print
>> statement, inside the Python interpreter, to page its
>> output? Write a function to page the output the way
>> you like, and assign it to sys.displayhook (see
>> http://docs.python.org/lib/module-sys.html#l2h-5124 )
> That seems interesting but it's not quite what I want to do. To take
> an example I would like to be able to do something similar to the
> mysql shell when its pager is set to less. Displayhook is called
> whenever an expression is being evaluated. I'd like to call 'less' on
> the ouput of a statement.
The only statement with any output that I can think of is "print". You
could define your own function and use it instead of print:
def p(x):
pydoc.pipepager(str(text), 'less')
and use p(something) instead of print something. (Else I totally
misundertood your problem)
--
Gabriel Genellina
More information about the Python-list
mailing list