Search code examples
pythonstringfunctionstubpycharm

Documentation String Stub, Python


I'm learning Python because I think is an awesome and powerful language like C++, perl or C# but is really really easy at same time. I'm using JetBrains' Pycharm and when I define a function it ask me to add a "Documentation String Stub" when I click yes it adds something like this:

"""

"""

so the full code of the function is something like this:

def otherFunction(h, w):
    """

    """
    hello = h
    world = w
    full_word = h + ' ' + w

    return full_word

I would like to know what these (""" """) symbols means, Thanks.


Solution

  • """ """ is the escape sequence for strings spanning several lines in python.

    When put right after a function or class declaration they provide the documentation for said function/class (they're called docstrings)