提供作爲參數傳遞給函數的字典項目的註釋的正確方法是什麼?這是下面一個例子,與定型,我做了(基於在谷歌文檔樣式獅身人面像):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