xxxxxxxxxx
Ctrl+/
For Both:
Ctrl+K+C
to comment
Ctrl+K+U
To uncomment
xxxxxxxxxx
#There is no way to comment multiple lines in Python.
#You just keep using "#" symbol to comment each line out.
'''
Technically you could also use triple single quotation
marks like so, but this formatting does not count
as "true" source code comments that are removed by
a Python parser.
'''
xxxxxxxxxx
# Select the lines and then press:
Pycharm - CTRL + / - comment / uncomment
Eclipse - CTRL + /- comment / uncomment
Sublime - CTRL + /- comment / uncomment
Atom - CTRL + /- comment / uncomment
IDLE - CTRL + ALT + 3 - comment, CTRL + ALT + 4 - uncomment
Notepad++ - CTRL + Q - comment / uncomment
vim - CTRL + Q / kbd>CTRL + V - comment / uncomment
VS Code - CTRL + / - comment / uncomment
In Python, you can comment multiple lines of code using either triple quotes or the "#" symbol at the beginning of each line.
Using triple quotes or using the "#" symbol:
xxxxxxxxxx
"""
This is a comment
on multiple lines
in Python
"""
# This is a comment
# on multiple lines
# in Python
Note that triple quotes can also be used to create multi-line strings, so make sure you don't confuse the two. If you want to comment out multiple lines of code, it's best to use the "#" symbol.
xxxxxxxxxx
# This is a "block comment" in Python, made
# out of several single-line comments.
# for this select the code and use shortcut Ctrl + /
xxxxxxxxxx
'''
This is a comment
And this is another comment
'''
# This is an un-commented line of code
x = 10
'''
This is a comment block,
spanning multiple lines,
that has been implemented to comment out multiple lines of code.
'''
# This is another un-commented line of code
y = 20
xxxxxxxxxx
# Multi-line comment select the lines to be commented.
Ctrl + 4.
# Unblock Multi-line comment.
Ctrl + 5.