提供作为参数传递给函数的字典项目的注释的正确方法是什么?这是下面一个例子,与定型,我做了(基于在谷歌文档样式狮身人面像):python字典评论
def class_function_w_dict_argument(self, T_in, c_temps):
""" This calculates things with temperatures
Notes:
All temperatures should be given in Kelvin
Args:
T_in (float): Known temperature (K)
c_temps (dict): Dictionary of component temperatures
{T1 (float): temperature (K)
T2 (float): temperature (K)
T3 (float): temperature (K)
T4 (float): temperature (K)
T5 (float): temperature (K)}
Returns:
T_out (float): Calculated temperature
"""
通常在这种情况下,你不使用字典,但**使用参数**:'t1','t2'等。这样的事实,参数传递,是*设计*。 –
我有一个不同的类,生成带有温度的格式化字典。如果能够传递整个字典(或者是用户自制的字典),而不是将其分割成单独的组件,然后将每个字典作为参数或类参数。 –
您是否正在寻找Sphinx *所需*的特定语法?否则,我不明白这如何不主要是基于意见的。 – chepner