Frage

I am using the pydoc.render_doc() to print help for a module, however it outputs a field labeled "DATA" which I don't wish to print. Is there any way to ommit that?

Here is an example of what it prints:

DATA
absolute_import = _Feature((2, 5, 0, 'alpha', 1), (2, 7, 0, 'alpha', 0...
War es hilfreich?

Lösung

Based on my reading of the PyDoc module source code there is no way to disable the printing of the bigsection headers.

Your best bet is to strip the DATA from the output before it is sent off to be consumed.

data = "D\x08DA\x08AT\x08TA\x08A\n" #  DATA bigsection header from pydoc
pydoc.render_doc(module).replace(data, '')

There are backspaces(\x08) in the bigsection header. This is explained here.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top