Comments within a line

Edward Diener eldiener at
Sat Jul 31 16:33:05 CEST 2004

Heike C. Zimmerer wrote:
> "Edward Diener" <eldiener at> writes:
>> Has there ever been any discussion of adding comments notation to
>> Python, such as C++'s /* */, which could occur in the middle of a
>> line or span multiple lines ? I would like to see it as a more
>> elegant solution for quickly commenting out code.
> In C/C++, you wouldn't use /* */ for commenting out code, since it
> would collide with any comment already there (comments can't be
> nested).

That's true but many times it will not, especially if one comments out code
within a line, or if one is using // liberally also.

>  Instead, the usual way is using #if 0 ... #endif.

Yes, this is the usual method in C++ which I often use, but Python has no

> You can use "if 0:" with python as well, but of course, you'd have to
> indent the entire commented-out block.  With most editors, this isn't
> much of a problem.  I usually use some smaller, "odd" indent than
> usual to have an indicication later where the block ends.

Decent idea. Still some sort of multi-line comment notation in Python would
be preferable.

More information about the Python-list mailing list