[Python-ideas] Comment syntax similar to /* */ in C?
debatem1 at gmail.com
Sun Oct 18 19:25:29 CEST 2009
On Sun, Oct 18, 2009 at 10:53 AM, Steven D'Aprano <steve at pearwood.info> wrote:
> On Mon, 19 Oct 2009 12:40:01 am Sturla Molden wrote:
>> P.S. In Python we can emulate multiline comments using triple-quoted
>> strings, but conceptually strings and comments are very different.
>> I.e. strings are objects, comments are auxillary text discarded at
>> compile time. Strings are objects created at runtime, comments are
> Guido's time-machine strikes again.
>>>> import dis
>>>> def test():
> ... x = 1
> ... """
> ... This is a triple-quote comment.
> ... """
> ... return x
> 2 0 LOAD_CONST 1 (1)
> 3 STORE_FAST 0 (x)
> 6 6 LOAD_FAST 0 (x)
> 9 RETURN_VALUE
> String literals -- not just triple-quoted strings, but any string
> literal -- that don't go anywhere are discarded by the Python compiler,
> precisely so they can be used as comments.
Did not know that, interesting.
More information about the Python-ideas