문제

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...
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top