Comments – How to mute your code

In every programing language is function to make comments in your code. Those are very important in sense of document your code for other and even your self. Comments help to structure the code, to explain what is going on and and to remember how your code works.

A good structured and commented code can safe a lot of time and money. A responsible programer will always document his code as good as possible. Imagine an old and retired programer leaves the company and has to be replaced by a new, probably younger employee. If the code contains no comments that describe what is going on, the new programer will have a hard time und understand the code. If the code is documented with comments, the new guy will get the functions way faster.

There are two different ways to make a comment in python. The first is using the hashtage (#) symbol to determine a comment. The second is using the three of the double quotes („““) to beginn and another three of them to close the comments.

If you put a hashtag (#) in front of code, the everything in the line, til the end of the line, will be ignored by python.

You can see that the code is grey and will be ignored by python. You can also put your comment in the middle of the line. Only the part after the hashtag will be ignored. The part before the hashtag is still valid and will be run by the program.

The second way to make comments using three double quotes works like this: open the comment with three double quotes („““). If that’s done, all the code is commented out until the very end. If you put a second time three of the double quotes, only the code between those two character groups are commented out.

Developers use comments not only to document their code but also to mute a part of the code, so I won’t be executed.

On this way you can test new codes while for example implementing new methods, without having to delete the old ones.

Kommentar hinterlassen

Trage deine Daten unten ein oder klicke ein Icon um dich einzuloggen:

Du kommentierst mit Deinem Abmelden /  Ändern )

Google Foto

Du kommentierst mit Deinem Google-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Twitter-Konto. Abmelden /  Ändern )


Du kommentierst mit Deinem Facebook-Konto. Abmelden /  Ändern )

Verbinde mit %s

Erstelle deine Website auf
Jetzt starten
%d Bloggern gefällt das: