[英]pydoc generated help-text with file handle parameters
I have a function with the following parameter list: 我有一个带有以下参数列表的函数:
def print(*line, sep=' ', end='\n', file=sys.stdout, default = 'full'):
Unfortunately the pydoc help text for the module shows it like this: 不幸的是,该模块的pydoc帮助文本显示如下:
FUNCTIONS
print(*line, sep=' ', end='\n', file=<_io.TextIOWrapper name='<stdout>' mode='w' encoding='cp850'>, default='full')
How can I make pydoc give the file argument as file=sys.stdout
rather than showing the gory details of the object? 如何使pydoc将文件参数指定为
file=sys.stdout
而不显示对象的血腥细节?
Python 3.2, by the way. 顺便说一下,Python 3.2。
Easy solution: 简单的解决方案:
def print(*line, sep=' ', end='\n', file=None, default = 'full'):
'''If file is None, defaults to sys.stdout.'''
if file is None:
file = sys.stdout
(But please consider not using print
and file
as identifiers. print
esp. will break Python 2-compatibility forever.) (但请考虑不使用
print
和file
的标识符。 print
ESP,将打破Python的2兼容性永远。)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.