我正在尝试为生成器函数编写一个:rtype:
类型提示。它返回的是什么类型?
例如,假设我有这个生成器函数,它产生字符串:
def read_text_file(fn):
"""
Yields the lines of the text file one by one.
:param fn: Path of text file to read.
:type fn: str
:rtype: ???????????????? <======================= what goes here?
"""
with open(fn, 'rt') as text_file:
for line in text_file:
yield line
返回类型不仅仅是字符串,而是一些字符串的可迭代对象?所以我不能只写:rtype: str
。正确的提示是什么?
:rtype:
的文档字符串。 - Moses Koledoye:rtype:
中插入文档字符串。它们是不同的事情。 - Woodrtype
)... - OrenIshShalom