Comments in functions


#1

Is there a specific reason that comments inside of functions use triple quotes (""") rather than the hashtag (#)? As far as I could see from my testing using # doesn’t impact the code at all. In fact, the only difference I could see what with regards to coloring in the code editor.

I first came across this in this exercise.


#2

Triple quotes create strings, those are not comments

Strings placed in certain places get picked up and added to that object’s attributes which can be used by documentation tools or looked up directly from within python

>>> def f():
...     'does all the things'
... 
>>> 
>>> help(f)
Help on function f in module __main__:

f()
    does all the things

>>>