Hash/# not a comment

2.2k Views Asked by At

G'day All,

I've searched far and wide (although using # in a search doesn't help much...) but what I need to do is use # in a line but not have it commented. I'm building a .kml within Python 2.7 and wish to apply a style and to do so, require the a '#' but as soon as I type it, python treats the following text as a comment. My code is as follows;

f.write("   <styleUrl>#Range" + str(row[3]) + "</description>\n")

What do I need to do to be able to type/print #?

1

There are 1 best solutions below

1
On BEST ANSWER

Python is not treating the following text as a comment. Your IDE might be mistakenly interpreting it as such and applying syntax highlighting incorrectly, but a # inside a quoted string is just a #, not the beginning of a comment.