Syntax, Example - Docstring - Python | Problem Solving and Python Programming : Data, Expressions, Statements

Chapter: Problem Solving and Python Programming : Data, Expressions, Statements

Docstring - Python

Docstring is short for documentation string.

DOCSTRING:

 

v   Docstring is short for documentation string.

v   It is a string that occurs as the first statement in a module, function, class, or method definition. We must write what a function/class does in the docstring.

v   Triple quotes are used while writing docstrings.

 

Syntax:

functionname__doc.__

 

Example:

def double(num):

"""Function to double the value"""

return 2*num

>>>     print(double.__doc__) Function to double the value

 

Tags : Syntax, Example , Problem Solving and Python Programming : Data, Expressions, Statements
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
Problem Solving and Python Programming : Data, Expressions, Statements : Docstring - Python | Syntax, Example

Related Topics

Problem Solving and Python Programming : Data, Expressions, Statements


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.