The aim of this post is to show you how to create comments in Python.
There are several ways to create them. But first, why should we actually use comments while programming? I mean you don’t have to. But coding without any comments is like playing soccer without any tactics or analyzation of the game. As if you and your teammates would never speak and analyze your aims and intentions behind certain actions on the soccer field. Not a good idea right? Going back to programming the main aims of comments are that they help to:
- Make code maintenance much easier
- Make finding bugs faster
- Write functions that other people will use
Creating comments in Python works like this:
- Use a “#” before writing down your code – the part after the Hashtag will not be compiled, but only shown as a text.
- Use obvious names for variables so if anybody else checks your code, can’t fail to understand the meaning of it.
- Last but not least you can use multiline comments by using the ”’ at the beginning and ”’ at the end of a comment.
How can option 1-3 look like in Python?
That’s pretty straightforward and I don’t want to overcomplicate it. What I still want to mention is that you and your coding team can think about “Documentation Standards”, which means that you define how to best write the documentation so that it helps you the most at the end.
After a soccer game a lot of players have to explain their thoughts and several situations about the game. So they leave a comment. To complete the article I will show you a selection of my favourite comments/quotes of soccer players:
- “If you’re attacking, you don’t get as tired as when you’re chasing” – Kyle Rote, Jr.
- “We lost because we didn’t win.” – Ronaldo
- “It was like the ref had a brand new yellow card and wanted to see if
it worked.” – Richard Rufus
- “I’d like to play for an Italian club, like Barcelona.” – Mark Draper
- “Eggs, we need Eggs” – Oliver Kahn