How To Write Comments in Python

Give Feedback

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.

victorariasvanegas on June 13, 2019

I think the first variant looks good.

Dri on Oct. 9, 2019

Agree, the first variant looks much better

Become a Member to join the conversation.