In python, we use triple commas to comment out multiple lines.
This is just one way to do this and you are technically using a string literal, not a comment. And, despite the fact that it has become quite durable, this way of writing comments has the drawback that you observed: you cannot comment on nested blocks. 1
Python has no nested multi-line comments, it's that simple. If you want to comment on multiple lines that allow nested comments, the only safe choice is to comment on each line.
Most editors have a command that simplifies commenting or a few lines.
1 For one level of nesting, you can use '''"""nested """'''
or vice versa. But I would not recommend it.
source share