Let's say I what to write a docstring for the code bellow:
def some_thing_cool(age, name):
better_age = age - 20
cooler_name = name + 'awesome'
bday_list = ['cake', 'balloons']
return bday_list
Would it be like this:
def some_thing_cool(age, name):
"""Something for bday
Args:
age (int) : age of bday person
name (string) : name of bday person
Variable:
better_age (int) : age - 20 for more pleasing age
cooler_name (string) : name + awesome
bday_list (list) : things to remember for bday
Returns:
bday_list (list) : best to return the list
"""
better_age = age - 20
cooler_name = name + 'awesome'
bday_list = ['cake', 'balloons']
return bday_list
Or should it be like this:
def some_thing_cool(age, name):
"""Something for bday
Args:
age (int) : age of bday person
name (string) : name of bday person
Returns:
bday_list (list) : best to return the list
"""
better_age = age - 20
cooler_name = name + 'awesome'
bday_list = ['cake', 'balloons']
return bday_list
And most importantly why should it be one way or another? (Do not think about the docstring style, this is not of importance in this question.) Most example I could find online does not include any variables when displaying how to write good docstrings, and this is constantly on my mind.