Hi, guys, I'd like to know, why should I live a (optional comment)
after the function?
Is it a must? cheers.
def spam():
"""Print 'Eggs!' to the console""" <<<<<<<---
print 'Eggs!'
spam()```
Edit: Oh wait, you meant the triple quotations
That for making a multi line comment
1 Like
def spam():
"""Print 'Eggs!' to the console"""
print 'Eggs!'
spam()
When the docstring
is written as the first line in a function it is reachable.
>>> def spam():
"""Print 'Eggs!' to the console"""
print ('Eggs!')
>>> def get_spam_docs():
print (spam.__doc__)
>>> get_spam_docs()
Print 'Eggs!' to the console
>>>
That’s not something we would actually do in a program, but rather in the inspection and documentation of the larger application.
1 Like