Commenting out a block of code

Is there a way to comment out a block of code in the script editor rather than using the # character for each line?


You can highlight the block of code and then do a Ctrl+/ to comment the entire block quickly, then to un-comment, highlight the entire block and press Ctrl+Shift+/ . Still uses # characters but it’s quick. Hope this helps.

I know it is old but maybe someone can help, I tried to do as suggested above but nothing happened…any suggestion? By the way, my keyboard is in AZERTY mode

Another way to comment out the block of code, which might work better for you, is by turning it into a string with triple quotes.
If you go to the very beginning of the block of code you want to comment out and type “”" that turns everything from that point onward in your code into a string. Then, you can go to the end of the block you want commented out and put another “”" to signify the end of the string. Since that whole block is now turned into a string, it is effectively commented out of your code. It’s a nice Python trick to know :slight_smile:

This works fine, thanks !

I do it this way,
I select the portion of the code i need to comment, starting from the bottom ( don’t ask me why, just trust me ), then i press ctrl + \ and then type # on multiple lines.