Explore Courses Blog Tutorials Interview Questions
+1 vote
1 view
in Python by (47.6k points)

Is there a mechanism to comment out large blocks of Python code?

Right now, the only way I can see of commenting out code is to either start every line with a #, or to enclose the code in triple quotes: """.

The problem with these is that inserting # before every line is cumbersome and """ makes the string I want to use as a comment show up in generated documentation.

2 Answers

0 votes
by (106k points)
edited by

In Python, we do not have such a mechanism. For commenting single line we use a # to each line. For more information see PEP 8. Most of the Python IDEs support a mechanism for block-commenting-with-pound-signs automatically for you. For example, in IDLE on my machine, it's Alt+3 and Alt+4.

To know more about this you can have a look at the following video tutorial:-

0 votes
by (32.3k points)

You can use the triple quotes for commenting out a block of code:-




Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.2k users

Browse Categories