Operating environment
CentOS release 6.8 (Final)
Python 2.6.6
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2599 / 12833)
Something called Docstrings was introduced. I've tried.
test_170331a.py
def my_echo(anything):
'''
prints [anything]
with an air of reserve
does not take [anything] seriously
'''
print("(in a small voice)"),
print("...")
print(anything)
print("...")
return
help(my_echo)
Run
$ python test_170331a.py
Help on function my_echo in module __main__:
my_echo(anything)
prints [anything]
with an air of reserve
does not take [anything] seriously
Docstrings related conventions https://www.python.org/dev/peps/pep-0257/
__doc__
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2628 / 12833)
An example of using __doc__
is introduced.
I've tried.
test_170331b.py
def my_echo(anything):
'''
prints [anything]
with an air of reserve
does not take [anything] seriously
'''
print("(in a small voice)"),
print("...")
print(anything)
print("...")
return
#help(my_echo)
print(my_echo.__doc__)
result
$ python test_170331b.py
prints [anything]
with an air of reserve
does not take [anything] seriously
Recommended Posts