SlickEdit Community
SlickEdit Product Discussion => SlickEdit® => Features and/or Improvements => Topic started by: jporkkahtc on October 30, 2017, 11:06:07 PM
-
Unfortunately Python doesn't support block comments.
So, people tend to use block quotes, """ or '''.
Ugh, but they do.
Slick oughta recognize this and treat them as comments.
For example if I have
a='''hello'''
then clearly, this is not a comment.
But, a stand alone string that isn't a function parameter or an assignment or otherwise part of an expression is a comment
'''
This is a block comment
'''
-
A regex can do a good job for color coding. This will require regex’s which do look behind.
-
Would it not be adequate to check if the triple-quote starts at the beginning of the line?
Even if that would work, we would also have to watch out for this:
a = (
"""
This is a real string.
Not a comment.
Strings should be strings.
Comments should be comments.
Don't cross the streams.
Why?
It would be bad.
"""
)
-
WRT beginning of the line: Unfortunately, no.
They can appear anywhere, so they must also get indented.
Worse yet doc strings: https://www.python.org/dev/peps/pep-0257/#rationale
So, if it is the first thing in a module, function or class, then it is assigned to the __doc__ attribute of the same.
So, does that count as a comment or a string?
I'd vote for comment - as it typically isn't going to be used by the script itself.
-
By beginning of line, I was referring to first-non-blank, not literally column 1.
-
Right, of course :-)
Thats probably pretty good.
A new color coding tag might be in order?
block-string
raw-string might be good too.