Not Just Paranoid

Another site by Pete Maynard

Programming Comments

It is good practice to include lots of comments in your code so that when you or someone else comes back and looks at the code you/they will understand what it is meant to do.

A comment will be ignored by the compiler, this means that anything in between the comment tags will not become a program. (Makes any scene?)

Normally there are two ways to write comments, one is a single line, and one is a multi line comment. There names explain what they mean.

So in Java and C++, a single line comment will look like this:

// Comment Text

And a multi line comment will look like this:

/*
More than one line
See!*/

In python a singe line comment is done like is:

# Comment text

And a multi lined comment will go like this:

" " " 
this is a multi line comment
which spans many lines
" " "

As you can see Java and C++ have the same way of creating comments but Python has a different way just to let you know that all languages do not have the same way of commenting text.

Useful Python Commenting Information

And for a small side note here is how to write comments in HTML.

HTML

<!-- Comment text in here -->

Hope this helps, Pete

9 Dec 2007

Website Last Updated on 15 Sep 2023 (CC BY-SA 4.0)

This site uses JQuery and nanogallery2 hosted by jsdelivr.net
for the Flickr photo feed and GoatCounter for user insights.