Environnement d'exploitation
CentOS release 6.8 (Final)
Python 2.6.6
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2599 / 12833)
Quelque chose appelé Docstrings a été introduit. J'ai essayé.
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)
Courir
$ 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
Conventions relatives aux Docstrings https://www.python.org/dev/peps/pep-0257/
__doc__
@ Introducing Python: Modern Computing in Simple Packages by Bill Lubanovic (No. 2628 / 12833)
Un exemple d'utilisation de «doc» est présenté. J'ai essayé.
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__)
résultat
$ python test_170331b.py
prints [anything]
with an air of reserve
does not take [anything] seriously
Recommended Posts