How to use multi_line comments in python | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

How to use multi_line comments in python

...

27th Jul 2018, 3:44 PM
Madhankumar S
Madhankumar S - avatar
5 Respostas
+ 1
Use triple-quoted strings. They are ignored when they are not a docstring.
27th Jul 2018, 3:50 PM
Steppenwolf
Steppenwolf - avatar
+ 1
'''hi this is multi line comment.''' using this ''' '''
27th Jul 2018, 4:04 PM
Maninder $ingh
Maninder $ingh - avatar
+ 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 ...
27th Jul 2018, 4:18 PM
HonFu
HonFu - avatar
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.
27th Jul 2018, 4:09 PM
Steppenwolf
Steppenwolf - avatar
- 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
27th Jul 2018, 3:55 PM
Facu
Facu - avatar