Ci sono alcuni tag per docstring in Python, come @param
e @return
, ad esempio:tag docstring per 'resa' parola chiave
def my_method(a_param):
''' @param a_param: Description of this param
@return: The return value of the method
'''
return int(a_param) * (other or 1)
cosa posso usare per documentare i generatori? specialmente il yield
parola chiave, come:
def my_generator(from=0):
''' @param from: The initial value
@yield: A lot of values
'''
yield a_value
Capisco che @return an iterator
può essere utilizzato qui, ma non so se è corretta, perché un generatore può restituire anche i valori.
Grazie.
Per quanto ne so, questi tag sono utilizzati da strumenti di terze parti e non da qualsiasi cosa in Python stesso. – Daenyth
Un generatore può "restituire" valori, restituisce un oggetto generatore. – agf