<br><br><div class="gmail_quote">On Sun, Oct 18, 2009 at 07:53, Steven D'Aprano <span dir="ltr"><<a href="mailto:steve@pearwood.info">steve@pearwood.info</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

<div class="im">On Mon, 19 Oct 2009 12:40:01 am Sturla Molden wrote:<br>
<br>
> In Python a comment start from # and spans the rest of the line,<br>
> similar to // in C++.<br>
><br>
> In C/C++, we can also make comments that don't span the rest of the<br>
> line, but has two delimiters:<br>
><br>
><br>
> /* comment */<br>
><br>
><br>
> This allows us to write:<br>
><br>
><br>
> foobar(a, b /* comment on b */, c, d, e, f);<br>
<br>
</div>Ewwww. That's horrible. If you ask me, in-expression comments are a<br>
misfeature the world would be better off without.<br>
<div class="im"><br>
> I have sometimes missed this possibility when writing Python code. To<br>
> my knowledge there is no equivalent to /* */ in Python.<br>
><br>
> I don't care much about choice of delimiter. Perhaps ### comment ###<br>
> is the most intuitive, as it has resemblance to triple-quotes for<br>
> text strings? It also stands out clearly in black/white text.<br>
><br>
><br>
> foobar(a, b ### comment on b ###, c, d, e, f)<br>
><br>
> foobar(a, b ### comment on b<br>
>   that spans two lines ###, c, d, e, f)<br>
<br>
</div>Take advantage of Python's rules for handling open parentheses:<br>
<div class="im"><br>
foobar(a, b, # comment on b<br>
 c, d, e, f)<br>
<br>
foobar(a, b, # comment on b<br>
</div> # more and longer comment on b<br>
 c, d, e, f)<br>
<br>
<br>
And don't forget that there's no need for comments to be on the same<br>
physical line they are referring to. You are allowed to include<br>
comments surrounding the line.<br>
<div class="im"><br>
<br>
> ###<br>
> comment that spans multiple lines<br>
> ###<br>
<br>
</div>Use a modern editor that lets you easily comment and uncomment multiple<br>
lines at once.<br>
<div class="im"><br>
<br>
<br>
> P.S. In Python we can emulate multiline comments using triple-quoted<br>
> strings, but conceptually strings and comments are very different.<br>
> I.e. strings are objects, comments are auxillary text discarded at<br>
> compile time. Strings are objects created at runtime, comments are<br>
> not.<br>
<br>
</div>Guido's time-machine strikes again.<br>
<br>
>>> import dis<br>
>>> def test():<br>
...     x = 1<br>
...     """<br>
...     This is a triple-quote comment.<br>
...     """<br>
...     return x<br>
...<br>
>>> dis.dis(test)<br>
  2           0 LOAD_CONST               1 (1)<br>
              3 STORE_FAST               0 (x)<br>
<br>
  6           6 LOAD_FAST                0 (x)<br>
              9 RETURN_VALUE<br>
<br>
<br>
String literals -- not just triple-quoted strings, but any string<br>
literal -- that don't go anywhere are discarded by the Python compiler,<br>
precisely so they can be used as comments.<br></blockquote><div><br></div><div>And because of this new syntax will never be added for multi-line comments. You guys can keep talking, but this is one of those "over Guido's resignation" type of proposals.</div>

<div><br></div><div>-Brett  </div></div>