How to write help / description text for Python functions

I recently started programming using Python. I have to write many functions and wondered how I can include help or description text so that it appears in the spyder object inspector when the function is called. In MatLab, this worked by placing a comment at the beginning of the function file. Is there a similar method in Python (using Spyder)?

+3
source share
2 answers

By default, the first line in the body of the method is used as its docstring (or documentation line). Python will use this when called for this method help().

def foo(bar):
    ''' Takes bar and does
        some things to it '''
    return bar

help(foo)
foo(bar)
    Takes bar and does
    some things to it

, , PEP-258 .

+13

(Spyder dev ) , ( , @burhan-khalid) Spyder:

  • , docstrings Object Inspector, numpydoc, . , python . , docstrings ( ) html.

  • Ctrl + I , .

+2

All Articles