How To Write Comments in Python

In this lesson, you’ll learn how to write comments in Python. You’ll see that comments are made by putting a “#” symbol before a desired comment. The lesson will also show you how to spread comments over multiple lines as well as how to write comments quickly in your editor using shortcuts,

Comments & Discussion

Rodrigo Vieira on March 13, 2019

Is the

"""Some module description

some module details
"""

more common than

"""
Some module description

some module details
"""

I particularly prefer the second one. Have you poked around any big project’s source codes to see what is more common?

Dan Bader RP Team on March 13, 2019

@Rodrigo: According to PEP 257 (Docstring Conventions), the first variant ("""Text...) is preferred. But personally I like the second variant better where each """ block is on its own line. It just looks better to me :-)

Jackie Wilson RP Team on March 14, 2019

I think the second variant looks better (in code) also. But then again, I prefer camelCase vs underscores.

Become a Member to join the conversation.