【发布时间】:2013-08-06 20:40:01
【问题描述】:
我如何记录函数返回 tuple 以使 PyCharm 能够将其用于类型提示?
人为的例子:
def fetch_abbrev_customer_info(customer_id):
"""Pulls abbreviated customer data from the database for the Customer
with the specified PK value.
:type customer_id:int The ID of the Customer record to fetch.
:rtype:???
"""
... magic happens here ...
return customer_obj.fullname, customer_obj.status #, etc.
【问题讨论】:
-
:returns:客户姓名:他的名字,客户状态:他的状态,客户的狗的名字:通常是Fido。
-
整个字符串不能只是
"""Return (name, status, etc)"""吗?其他一切似乎有点多余。除非 PK 值与函数期望的 customer_id 类型有关。 -
更新了问题文本以减少主观性。