Question

In my editor (notepad++) in Python script edit mode, a line

## is this a special comment or what?

Turns a different color (yellow) than a normal #comment.

What's special about a ##comment vs a #comment?

Was it helpful?

Solution

From the Python point of view, there's no difference. However, Notepad++'s highlighter considers the ## sequence as a STRINGEOL, which is why it colours it this way. See this thread.

OTHER TIPS

I thought the difference had something to do with usage:

#this is a code block header

vs.

##this is a comment

I know Python doesn't care one way or the other, but I thought it was just convention to do it that way.

Also, in a different situations:

Comment whose first line is a double hash:

This is used by doxygen and Fredrik Lundh's PythonDoc. In doxygen, if there's text on the line with the double hash, it is treated as a summary string. I dislike this convention because it seems too likely to result in false positives. E.g., if you comment-out a region with a comment in it, you get a double-hash.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top