[PYTHON] Docstrings

def players(**kwargs):
    """A function that outputs the name and occupation.
    """
    for name, job in kwargs.items():
        print(name + 'Is' + job + 'is.')

d = {
    'Taro':'Brave',
    'Jiro':'Warrior',
    'Saburo':'Wizard',
    'Shiro':'Monk'
}

players(**d)    
print(players.__doc__)
help(players)

Execution result


Taro is a brave man.
Jiro is a warrior.
Saburo is a witch.
Shiro is a monk.
A function that outputs the name and occupation.
    
Help on function players in module __main__:

players(**kwargs)
A function that outputs the name and occupation.

Functions of functions, etc. Write in "" "" "". Can be referenced with the doc method. You can also refer to it with the help function.

Recommended Posts

Docstrings