Barthelemy
Barthelemy

Reputation: 8757

How to create a scrollable screen in text mode with Python

I would like to create a scrollable screen in text mode, like the one obtained when typing help(object) in the interpreter. Is there a cross-platform module I can use to easily implement this?

For example:

>>> def jhelp(object):
>>>     text = # get text for object
>>>     display_text(text) # display a scrollable screen. How do I do this?
>>>
>>> l = [1,2,3]
>>> jhelp(l)

Upvotes: 6

Views: 1245

Answers (3)

asmeurer
asmeurer

Reputation: 91490

I think what you really want is from pydoc import pager. ttypager is a very reduced pager, but pager will automatically use a better pager (basically less) if it is available.

Upvotes: 2

pwdyson
pwdyson

Reputation: 1177

from pydoc import ttypager

def jhelp(object):
     text = # get text for object
     ttypager(text) # display a scrollable screen.

Upvotes: 4

mg.
mg.

Reputation: 8012

look at pydoc module in the standard library

Upvotes: 0

Related Questions