Redirecting input of IDLE window
Peter Otten
__peter__ at web.de
Mon Aug 14 10:56:21 EDT 2017
Friedrich Rentsch wrote:
> Hi,
>
> I work interactively in an IDLE window most of the time and find
> "help (...)" very useful to summarize things. The display comes up
> directly (doesn't return a text, which I could edit, assign or store). I
> suspect that there are ways to redirect the display, say to a file.
> Thanks for suggestions.
>
>
> Frederic
Here's a simple example for a custom pager that stores the last help text as
a string:
>>> import pydoc
>>> def mypager(text):
global last_help
text = pydoc.plain(text)
last_help = text
print(text)
>>> pydoc.pager = mypager
>>> help(help)
Help on _Helper in module _sitebuiltins object:
class _Helper(builtins.object)
| Define the builtin 'help'.
|
| This is a wrapper around pydoc.help that provides a helpful message
<snip>
>>> last_help.splitlines()[0]
'Help on _Helper in module _sitebuiltins object:'
More information about the Python-list
mailing list