You can either use help() or print the __doc__. help() prints a more verbose description of an object while __doc__ holds only the documentation string you have defined with triple quotes """ """ in the beginning of your function.
For example, using __doc__ explicitly on the sum built-in function:
print(sum.__doc__)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers
When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.
Additionally, since Python first compiles an object and during execution evaluates it you can call __doc__ within the function with no problems:
def foo():
"""sample doc"""
print(foo.__doc__)
foo() # prints sample doc
and remember, besides functions, modules and classes have a __doc__ attribute holding their documentation.
Alternatively, using help() for sum:
help(sum)
Will print:
Help on built-in function sum in module builtins:
sum(iterable, start=0, /)
Return the sum of a 'start' value (default: 0) plus an iterable of numbers
When the iterable is empty, return the start value.
This function is intended specifically for use with numeric values and may
reject non-numeric types.
gives a bit more information, including the docstring.
Answer from Dimitris Fasarakis Hilliard on Stack OverflowVideos
I like to have a book to learn from when learning a language. I learn the book as much as I learn the language, then the book becomes my indespensible programming companion. I'd happily buy it in book form if it's available, is it? Compiling a word file from all the python.org documentation (Tutorial, Standard library, Python language reference) with copy/paste seems very daunting, or is there a slick way to do that? I wish python.org made a single document of everything so I could print it and have it spiral bound.
Thanks....
» pip install tabulate