0
How to use multi_line comments in python
...
5 Réponses
+ 1
Use triple-quoted strings. They are ignored when they are not a docstring.
+ 1
'''hi this
is multi line
comment.'''
using this ''' '''
+ 1
Try writing this in a script and run it:
'g'
5
[6,7,8]
{3}
frozenset([6])
''' Rock 'n Roll '''
It will run and nothing will happen. So technically you could comment in a lot of strange ways.
But actually the interpreter reads all of this: It creates anonymous objects for a second. So this should impact performance somewhat, right?
The question would come down to if ''' '''-strings in the middle of the script are ignored by the interpreter or not ...
0
Facu, still there is one trick https://code.sololearn.com/cNpZx907q99h/?ref=app
Unlike comments, triple-quoted strings are being parsed and must be syntactically valid, regardless of where they appear in the code. Perhaps using them is not a good practice, but it still works in some way.
- 1
I'm sorry, but I think there are no multiline comments in Python, according to the course. There is only one line and docstring