[Python-ideas] Multi-line comment blocks.

Steven D'Aprano steve at pearwood.info
Sat Jun 16 09:17:35 CEST 2012

Devin Jeanpierre wrote:

> In contrast, the reason that multiline comments are so great is that
> they can go virtually anywhere without too much concern. For example:
>     def foo(a, b(*=None*)):
>         ...

So now you're changing the semantics from *multiline* to *embedded* comments. 
Being able to embed a comment within an expression is a very different thing 
from just having comments extend across multiple lines.

> In this hypothetical code, I commented out the =None in order to run
> the test suite and see if any of my code omitted that argument, maybe
> to judge how reasonable it is to remove the default. Here, neither "#"
> comments nor docstrings really make this easy. The closest equivalent
> is:
>     def foo(a, b): #=None):
>         ...

The simplest change here would be to just delete the "=None", run your tests, 
then put it back if the tests fail.

Of course, alternatives are the comment above, or perhaps even better:

     #def foo(a, b=None):
     def foo(a, b):

which avoids the risk of forgetting what change needs to be undone.

In any case, all these alternatives are so trivial that they are hardly an 
argument for adding new comment syntax.

> And that has to be done entirely by hand, and might be especially
> painful (involving copy-paste) if it isn't the last argument that's
> being changed.

"Especially painful"? I fear you exaggerate somewhat.


More information about the Python-ideas mailing list