Python comments

Ok, I know about the # symbol to place a comment in python. I’ve seen a block commented out in example code using
“”"
some text
“”"
This works if I got the code from a download and on some code blocks.
Sometimes when I use this to comment out a block of code then I get a ‘SyntaxError: invalid syntax’ on first line after the ending “”" when doing the make.py
If I comment out each line with a # I don’t get the error.
I have tried all kinds of combination of blank lines, etc but just can’t figure this one out.
I’ve looked at the text files in a binary viewer and both he examples and what I type are the same characters a 0x22.

I tried searching the Python documents but couldn’t find anything on using “”“\ … “”” to comment out of block.

Anyone know how this should work?

The “”" syntax is not intended for use as a commenting tool, per se. It creates an actual obejct – it is the syntax for more easily creating a multi-line string. Section 3.1.2 of the Python tutorial (http://www.python.org/doc/2.4.3/tut/node5.html) notes the syntax, for instance.

It is commonly used when creating documentation strings. In these cases, the “string” content might look like a comment, but the placement (the first line of the body of the module file / class / function, etc.) indicates a documentation string. It will be available in the “doc” member of the corresponding object, as with all other documentation strings. Section 4.7.6 of the Python tutorial (http://www.python.org/doc/2.4.3/tut/node6.html) gives examples of this usage of the “”" syntax for creating the documentation string for a function.

Also note that the text you include within the “”" is actually included in the ZIP file you upload to the gateway, and if you are a good documenter it will add 10-20% to the ZIP size. I strip them from my own ZIP builds (but leave them in Dia since I don’t want a custom make.py).

It is not trivial to strip them in 2.4 since there is a bug in the standard tokenize package which treats dictionary items like { 123 : “hello” } the same as a def func(): “”" Here is the multiline"“”. So when you strip the doc_strings, your dictionary becomes { 123 : } and you have broken code.

Ah…that’s why I couldn’t find the info when searching the python docs. I searched for ‘comment’.
Python sure is a powerful language. I’m just getting started on learning it.
That does explain what was going on.
Thanks.