Betriebsumgebung
CentOS release 6.8 (Final)
Python 2.6.6
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2599 / 12833)
Etwas namens Docstrings wurde eingeführt. Ich habe es versucht.
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)
Lauf
$ 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-bezogene Konventionen https://www.python.org/dev/peps/pep-0257/
__doc__
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2628 / 12833)
Ein Beispiel für die Verwendung von doc wird vorgestellt. Ich habe es versucht.
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__)
Ergebnis
$ python test_170331b.py
prints [anything]
with an air of reserve
does not take [anything] seriously
Recommended Posts