Mutliple Line Comments


Why does my comment print out in the interpreter?

Replace this line with your code. Do not remove the backticks that are above or beneath this line.


That would suggest that it's not a comment. Perhaps it's a multiline string.


Then how would you write multi-line comments without triple apostrophes? And why did the comment print to the console?


If you would post your code, it would be easier to tell...


If you did not print it then you did not print it. If somebody else printed it then that's not your problem.

Literals, including strings, get ignored if they are not used, that means that sure, strings can be used as comments.

When placed in certain locations they become docstrings instead, they get associated with that module/class/function. You can for example print the docstring for sum with: print sum.__doc__

Most text editors intended for writing code support (de)commenting lines, there really isn't much need for the syntax supporting multi-line comments. (Fro example, in vim I might type the following to comment this and the following 4 lines: 0(ctrl+v)5jI#(ESC) That makes lots and lots of sense I'm sure :p)