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 Overflow
🌐
Python documentation
docs.python.org › 3 › library › functions.html
Built-in Functions — Python 3.14.3 documentation
February 27, 2026 - All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values.
🌐
W3Schools
w3schools.com › python › ref_func_print.asp
Python print() Function
Python Examples Python Compiler ... Python Certificate Python Training ... The print() function prints the specified message to the screen, or other standard output device....
🌐
Python documentation
docs.python.org › 3 › tutorial › inputoutput.html
7. Input and Output — Python 3.14.3 documentation
Formatted string literals (also called f-strings for short) let you include the value of Python expressions inside a string by prefixing the string with f or F and writing expressions as {expression}. An optional format specifier can follow the expression. This allows greater control over how the value is formatted. The following example rounds pi to three places after the decimal: >>> import math >>> print(f'The value of pi is approximately {math.pi:.3f}.') The value of pi is approximately 3.142.
🌐
Python Reference
python-reference.readthedocs.io › en › latest › docs › functions › print.html
print — Python Reference (The Right Way) 0.1 documentation
All non-keyword arguments are converted to strings like str() does and written to the stream, separated by sep and followed by end. Both sep and end must be strings; they can also be None, which means to use the default values. If no objects are given, print() will just write end.
🌐
Python
python.org › doc
Our Documentation | Python.org
Python's documentation, tutorials, and guides are constantly evolving. Get started here, or scroll down for documentation broken out by type and subject. ... Download Current Documentation (multiple formats are available, including typeset versions for printing.)
🌐
Real Python
realpython.com › python-print
Your Guide to the Python print() Function – Real Python
June 25, 2025 - >>> print("My age is: " + 42) Traceback ... File "<python-input-0>", line 1, in <module> print("My age is: " + 42) ~~~~~~~~~~~~~~^~~~ TypeError: can only concatenate str (not "int") to str · Apart from accepting a variable number of positional arguments, print() defines four named or keyword arguments, which are optional since they all have default values: You can view their brief documentation by calling ...
Find elsewhere
🌐
Python
docs.python.org › 3 › library › pprint.html
pprint — Data pretty printer — Python 3.14.3 documentation
pprint — Data pretty printer · Functions · PrettyPrinter Objects · Example · copy — Shallow and deep copy operations · reprlib — Alternate repr() implementation · Report a bug · Improve this page · Show source · « · index · modules | next | previous | Python » · 3.14.3 Documentation » ·
🌐
LearnPython.com
learnpython.com › blog › python-print-function
A Complete Guide to the Python print() Function | LearnPython.com
January 25, 2022 - Also, try printing the sequence given by the built-in function range() with and without the star. We’ll see some more examples with starred expressions in the next section. The second argument of the Python print() function defines the separator.
🌐
Python documentation
docs.python.org › 3 › tutorial › controlflow.html
4. More Control Flow Tools — Python 3.14.3 documentation
The Python parser strips indentation from multi-line string literals when they serve as module, class, or function docstrings. ... >>> def my_function(): ... """Do nothing, but document it. ... ... No, really, it doesn't do anything: ... ... >>> my_function() ... >>> ... """ ... pass ... >>> print(my_function.__doc__) Do nothing, but document it.
🌐
Python documentation
docs.python.org › 3 › library › stdtypes.html
Built-in Types — Python 3.14.3 documentation
February 25, 2026 - Some operations are supported by several object types; in particular, practically all objects can be compared for equality, tested for truth value, and converted to a string (with the repr() function or the slightly different str() function). The latter function is implicitly used when an object is written by the print() function.
🌐
Reddit
reddit.com › r/python › python official documentation in book/hardcopy form
r/Python on Reddit: Python Official Documentation in book/hardcopy form
September 28, 2023 -

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....

🌐
Code.mu
code.mu › en › python › book › supreme › functions › function-documentation-output
Printing Function Documentation in Python
Create a function that will take a list of month names as a parameter and output them with a capital letter. Describe the essence of the function in the documentation and output it to the console. Print all documentation about the function sum.
🌐
PyPI
pypi.org › project › tabulate
tabulate · PyPI
Tabulate is a Python3 library. The second optional argument named headers defines a list of column headers to be used: >>> print(tabulate(table, headers=["Planet","R (km)", "mass (x 10^29 kg)"])) Planet R (km) mass (x 10^29 kg) -------- -------- ...
      » pip install tabulate
    
Published   Mar 04, 2026
Version   0.10.0
🌐
Python
python.org
Welcome to Python.org
# Simple output (with Unicode) >>> print("Hello, I'm Python!") Hello, I'm Python! # Input, assignment >>> name = input('What is your name?\n') What is your name?
🌐
Programiz
programiz.com › python-programming › docstrings
Python Docstrings (With Examples)
''' print("Hello World") Note: We use triple quotation marks for multi-line strings. ... As mentioned above, Python docstrings are strings used right after the definition of a function, method, class, or module (like in Example 1). They are used to document our code.
🌐
GitHub
github.com › python › cpython › issues › 94286
The documentation for the print() builtin should perhaps say file=None as default · Issue #94286 · python/cpython
June 26, 2022 - Documentation The current function definition for the print() builtin at https://docs.python.org/3/library/functions.html#print reads: print(*objects, sep=' ', end='\n', file=sys.stdout, flush=False) However, this suggests that the defau...
Author   juliangilbey
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-docstrings
Python Docstrings - GeeksforGeeks
September 19, 2025 - def my_func(): """This is a docstring using triple double quotes.""" return None print(my_func.__doc__) ... This is a docstring using triple double quotes. Google style docstrings follow a specific format and are inspired by Google's documentation style guide. They provide a structured way to document Python code, including parameters, return values and descriptions.
🌐
Quora
quora.com › What-is-a-Python-script-to-print-the-docstring-documentation-string-of-the-input-function
What is a Python script to print the docstring (documentation string) of the input function? - Quora
Answer (1 of 2): The docstring of a function is automatically parsed by Python into the [code ]__doc__[/code] attribute of this function. [code]>>> def my_function(): ... """Return 2, and do nothing else.""" ... a = 1 + 1 ... return >>> print(my_function.__doc__) Return 2, and do not...