I am having trouble printing a docstring after importing it into my terminal window using the python interpreter. After typing python in my terminal window I enter in the following code:
import pizza
print(make_pizza.__doc__)
The print statement gives me a NameError saying make_pizza is not defined. The pizza module contains the following function:
def make_pizza(size, *toppings):
"""Summarize the pizza we are about to make"""
When I use the function it works just fine so it must be defined. There is other code for the function, but for simplicity I just want to know how to print the docstring in my terminal window. Any ideas?
You need to include the module name. Try
print(pizza.make_pizza.__doc__)