A comment in Python starts with the hash character, # , and extends to the end of the physical line. A hash character within a string value is not seen as a comment, though. To be precise, a comment can be written in three ways - entirely on its own line, next to a statement of code, and as a multi-line comment block.
You can comment out one or more lines of code in any C/C++ editor view. The leading characters // are added to the beginning of each line when commenting one or more lines of code. You can also block comment multiple lines of code using the characters /* */ .
I am doing an optimization problem and writing a gigantic list. I would like to insert comments inside the list like below
my_rhs = [1.0, 1.0, 0.0, 0.0, 0.0,\ #comment1
-1.0, -1.0, -1.0,\ #comment2
0.0, 0.0, 0.0]
but when I do this Python gives an error. How can I comment in the places shown? I tried defining each line as a new list and using +
to append but that doesn't seem to work either. Like below
my_rhs = [1.0, 1.0, 0.0, 0.0, 0.0]+\ #comment1
[-1.0, -1.0, -1.0]+\ #comment2
[0.0, 0.0, 0.0]
How can I comment in the shown locations without Python giving an error?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With