# The comment block for Python

**URL:** <https://discuss.python.org/t/the-comment-block-for-python/108396>\
**Category:** Ideas\
**Created:** [August 4, 2026, 3:21pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396 "2026-08-04T15:21:08Z")\
**Posts on this page:** 18\
**Page:** 2

<div class="post-metadata">

**Author:** ![nedbat](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/nedbat/32/8744_2.png) [@nedbat](https://discuss.python.org/u/nedbat)\
**Post date:** [August 4, 2026, 10:51pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/23 "2026-08-04T22:51:37Z")

</div>

> [@uzyfabbargama](#):
>
> ```python
> sed -i 's/^#"""/##"""/g' file.py
> sed -i 's/^##"""/#"""/g' file.py
> 
> ```

If I’m not mistaken, the second line will undo the effect of the first line, no? If you want to manipulate lines with sed, you should use markers in your comments:

```python
#:section 1
blah blah
#:end
##:section 2
#blah blah
##:end

```

Then you can use

```python
sed -i '/:section 1/,/:end/s/^/#/' file.py
sed -i '/:section 2/,/:end/s/^#//' file.py

```

to swap which part is commented out. No changes to Python needed, it works now. Plus, you have readable labels to the sections.

Manipulating Python code with sed is a very unusual use-case, but it’s one that today’s Python is already accommodating.

---

<div class="post-metadata">

**Author:** ![gcewing](https://avatars.discourse-cdn.com/v4/letter/g/3d9bf3/32.png) [@gcewing](https://discuss.python.org/u/gcewing)\
**Post date:** [August 5, 2026, 12:22am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/24 "2026-08-05T00:22:14Z")

</div>

That looks quite confusing to read. You need to take notice of exactly  
how many #s there are to tell which parts are active. – but only on  
lines where the # is followed by “”". No longer can you just skim and  
ignore any line that starts with #.

Also it’s rather specialised, allowing you to toggle between 2 versions,  
but not choose one of 3 or more.

---

<div class="post-metadata">

**Author:** ![tstefan](https://avatars.discourse-cdn.com/v4/letter/t/f475e1/32.png) [@tstefan](https://discuss.python.org/u/tstefan)\
**Post date:** [August 5, 2026, 12:40am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/25 "2026-08-05T00:40:28Z")

</div>

```python
def verify(filename, clear_payload):
    #"""
    # I would like to verify if the PNG is valid and not corrupt but Pillow .verify() is not yet implemented
    im = Image.open(filename)
    im.verify()
    im.close()
    #"""
    content = open(filename, "rb").read()

```

> [@Rosuav](#):
>
> This would suddenly disable code that is meant to be active. I’m not sure what the author’s intent is here, but this block of code would change meaning under your proposal.

This is actually not a totally uncommon pattern; the code snippet can be “deactivated” by one keystroke:

```python
def verify(filename, clear_payload):
    """
    # I would like to verify if the PNG is valid and not corrupt but Pillow .verify() is not yet implemented
    im = Image.open(filename)
    im.verify()
    im.close()
    #"""
    content = open(filename, "rb").read()

```

This turns these few lines into a multi-line string literal that is just discarded. This construct can be (ab)used as a multi-line comment. (In this particular case, it is a doc string, but maybe the author did not care about this.)

---

<div class="post-metadata">

**Author:** ![blhsing](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/blhsing/32/25812_2.png) [@blhsing](https://discuss.python.org/u/blhsing)\
**Post date:** [August 5, 2026, 8:46am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/26 "2026-08-05T08:46:44Z")

</div>

> [@uzyfabbargama](#):
>
> `/* */`: These are some ideas from the community to address this, but in my opinion (I don’t know if you share it) they are anti-Python, think about it, adds unnecessary syntactic overhead, and the solutions are quite generic; we need something more in the style of Python.

I don’t see what’s so anti-Python about `/* */` when Python already borrowed a good number of syntaxes from C++. To me that’s the most natural choice if we are to add a multiline comment syntax to Python. The fact that it’s an outright invalid syntax in Python today also makes it more viable than your proposed syntax.

---

<div class="post-metadata">

**Author:** ![xitop](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/xitop/32/13242_2.png) [@xitop](https://discuss.python.org/u/xitop)\
**Post date:** [August 5, 2026, 9:37am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/27 "2026-08-05T09:37:48Z")

</div>

Here is a related idea. I find the following more useful than a proposed comment block alone, but I probably wouldn’t propose it outside of this topic.

- triple quoted h-string (Inspired by shell **h** eredoc):

```python
h"""somename

# this string can contain other triple-quote strings
# because its endquote is marked with 'somename'

def commented_out_function():
    """
    docstring
    """
    return

"""somename

```

- n-string ( **n** oop)  
It’s a string that is thrown away by the parser and because of that it doesn’t have  
to follow indentation rules.

```python
def func(a, b):
    x = a * b
n"""
    # I'm not here, this is not happening
    print(a, b, x)
"""

```

Each of them could be sometimes useful on its own. And combined into a nh-string they form a universal comment block.

---

<div class="post-metadata">

**Author:** ![UnknownUser03393](https://avatars.discourse-cdn.com/v4/letter/u/f9ae1b/32.png) [@UnknownUser03393](https://discuss.python.org/u/UnknownUser03393)\
**Post date:** [August 5, 2026, 3:08pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/29 "2026-08-05T15:08:05Z")

</div>

So why not just use this?

```python
"""
comment block
"""

```

The IDE recognizes this (as same as Function’s Documention).

---

<div class="post-metadata">

**Author:** ![Stefan2](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/stefan2/32/18492_2.png) [@Stefan2](https://discuss.python.org/u/Stefan2)\
**Post date:** [August 5, 2026, 3:17pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/30 "2026-08-05T15:17:06Z")

</div>

What is that? The same as the first post?

---

<div class="post-metadata">

**Author:** ![JoBe](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jobe/32/26961_2.png) [@JoBe](https://discuss.python.org/u/JoBe)\
**Post date:** [August 5, 2026, 5:32pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/31 "2026-08-05T17:32:10Z")

</div>

Only problem is that `>>>` is used in docstrings to indicate the REPL. If tools then evaluate the code in a docstring (which a few testing tools do), that would likely raise a syntax error, resulting in breaking tests?!

---

<div class="post-metadata">

**Author:** ![jonathandung](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jonathandung/32/35459_2.png) [@jonathandung](https://discuss.python.org/u/jonathandung)\
**Post date:** [August 6, 2026, 8:27am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/32 "2026-08-06T08:27:45Z")

</div>

I like the heredoc string. It is loosely reminiscent of Rust raw string literals, but much more readable because the delimiters are on their own lines and can serve a documentation purpose like a small comment already. Maybe you can propose it in a separate thread.

---

<div class="post-metadata">

**Author:** ![jsbueno](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jsbueno/32/1210_2.png) [@jsbueno](https://discuss.python.org/u/jsbueno)\
**Post date:** [August 6, 2026, 3:56pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/33 "2026-08-06T15:56:58Z")

</div>

Oh yeah - nothing like conflicting with git conflict markers themselves. That would be astonishing!

---

<div class="post-metadata">

**Author:** ![ssokolow](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ssokolow/32/32572_2.png) [@ssokolow](https://discuss.python.org/u/ssokolow)\
**Post date:** [August 9, 2026, 11:54am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/34 "2026-08-09T11:54:32Z")

</div>

> [@Rosuav](#):
>
> You seem to have something against IDEs. I don’t blame you for disliking the heavyweight “all-inclusive” IDEs, but there are plenty of text editors that don’t use a huge amount of RAM, and yet have a way to block comment/uncomment code in various languages. For example, the editor I use is [SciTE](https://scintilla.org/SciTE.html), and I can select a block of text and hit Ctrl-Q to toggle comment; and this works in basically any language. I’m not sure what you’ll consider a fair test of measure memory usage, but I keep SciTE running permanently on my laptop with 4GB of memory; he struggles to load web pages with too much JS in them some days, but SciTE is still lean. According to top it’s using about 20MB of RSS, putting it roughly comparable to (and a little below) Thunar the file manager.
> 
> All this is not to say that this is a useless proposal, but just that the juice isn’t worth the squeeze.

While I do share the belief that “the juice isn’t worth the squeeze”, I also understand the opposite perspective because it’s one that was expressed more explicitly when I was practically subscribed to the RFCs repo in Rust’s early days.

In essence, design your language on the assumption that the user will be using something like notepad.exe so IDE/programmer’s text editor features have a high baseline to improve on.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [August 9, 2026, 12:21pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/35 "2026-08-09T12:21:13Z")

</div>

> [@ssokolow](#):
>
> In essence, design your language on the assumption that the user will be using something like notepad.exe so IDE/programmer’s text editor features have a high baseline to improve on.

There is some validity to this. However, I don’t really see a problem with the status quo for that. Yes, if you’re in Notepad, you have to press #, down, left, #, down, left, until you get every line commented out. That’s the baseline that even a basic text editor can easily improve on, but it’s also a baseline that is entirely workable (I’ve done the exact same thing for bulk edits in myriad contexts).

---

<div class="post-metadata">

**Author:** ![ssokolow](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/ssokolow/32/32572_2.png) [@ssokolow](https://discuss.python.org/u/ssokolow)\
**Post date:** [August 10, 2026, 5:30pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/36 "2026-08-10T17:30:51Z")

</div>

> [@Rosuav](#):
>
> There is some validity to this. However, I don’t really see a problem with the status quo for that. Yes, if you’re in Notepad, you have to press #, down, left, #, down, left, until you get every line commented out. That’s the baseline that even a basic text editor can easily improve on, but it’s also a baseline that is entirely workable (I’ve done the exact same thing for bulk edits in myriad contexts).

In greenfield design, I’d say that having a multi-line comment syntax like `/* */` becomes more valuable the longer the span you want to comment out. However, In this context, I’ll restate that I don’t think “the juice is worth the squeeze” for adding a new syntax… especially when multi-line strings can be abused as multi-line comments.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [August 10, 2026, 7:59pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/37 "2026-08-10T19:59:39Z")

</div>

> [@ssokolow](#):
>
> In greenfield design, I’d say that having a multi-line comment syntax like `/* */` becomes more valuable the longer the span you want to comment out.

Yes, but also, it quickly gets to the problem of nesting. Most languages do not allow those comments to be nested; which means, if you’re commenting out a large block of code and it happens to contain another /\* \*/ comment, the comment stops short.

(And if they CAN be nested, you have to be paranoid about having those characters together inside a quoted string, lest you get the opposite problem.)

---

<div class="post-metadata">

**Author:** ![ZeeD](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/zeed/32/3547_2.png) [@ZeeD](https://discuss.python.org/u/ZeeD)\
**Post date:** [August 11, 2026, 6:39am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/38 "2026-08-11T06:39:43Z")

</div>

just to add my 2¢

I don’t particularly like block comments and avoid using them in languages where they are available, because they “broke” my greps.

If I search (with grep or my IDE) for something (like a function invocation) it’s very easy to detect lines that are commented out wth ‘#’ (or ‘//’ or ‘–’).

it’s a bit more cumbersome with block comments, as I need to open the file and look for the context to understand if it’s “actual” code or not.

---

<div class="post-metadata">

**Author:** ![uzyfabbargama](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/uzyfabbargama/32/36851_2.png) [@uzyfabbargama](https://discuss.python.org/u/uzyfabbargama)\
**Post date:** [August 11, 2026, 9:00pm UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/39 "2026-08-11T21:00:36Z")

</div>

> **[HQQQ/en at main · uzyfabbargama/HQQQ](https://github.com/uzyfabbargama/HQQQ/tree/main/en)**
>
> main/en

More info here, about of most questions (not all) for check-in, thanks for comment in my first post.

---

<div class="post-metadata">

**Author:** ![jonathandung](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/jonathandung/32/35459_2.png) [@jonathandung](https://discuss.python.org/u/jonathandung)\
**Post date:** [August 12, 2026, 12:12am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/40 "2026-08-12T00:12:52Z")

</div>

Your repository doesn’t answer any of the pressing questions (backwards incompatibility for one) but is instead an unconvincing AI-generated pitch of your idea. It would be great if you showed that your idea is unequivocally better than what IDEs can already do and found a way to mitigate the change breaking currently valid code first.

---

<div class="post-metadata">

**Author:** ![Stefan2](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/stefan2/32/18492_2.png) [@Stefan2](https://discuss.python.org/u/Stefan2)\
**Post date:** [August 12, 2026, 7:07am UTC](https://discuss.python.org/t/the-comment-block-for-python/108396/41 "2026-08-12T07:07:20Z")

</div>

Had a look at your GitHub page.

You present these quotes:

> “Not everything that is efficient is beautiful. But this is both.”

> “Not everything that is efficient is beautiful. But HQQQ is both.”

Who are you quoting? Who said that? Was it one of the people mentioned in “Acknowledgements” that you’re making look like supporters of this?

You’re thanking Ned for the sed corrections, but you’re not using them, instead showing your original buggy sed commands.

[Previous page](https://discuss.python.org/t/the-comment-block-for-python/108396.md?page=1)
