A simple single line, triple-quoted comment is giving syntax error. Why?

Jean-Michel Pichavant jeanmichel at sequans.com
Tue Mar 31 07:38:17 EDT 2015


----- Original Message -----
> From: "Terry Reedy" <tjreedy at udel.edu>
> To: python-list at python.org
> Sent: Wednesday, 18 March, 2015 10:47:40 PM
> Subject: Re: A simple single line, triple-quoted comment is giving syntax error. Why?
> 
> On 3/18/2015 3:53 PM, Thomas 'PointedEars' Lahn wrote:
> 
> > I must strongly object and recommend against getting accustomed to
> > the
> > suggested use of multi-line string literals.
> 
> I agree.

I remember loosing a lot of time finding a bug that can be summarized like this (immagine a much larger list where the temptation of commenting a block is high):

a =  [	'1',
'''shorten the list to speedup tests
        '2',
        '3',
'''
        '4',
        ]


print a
>>> ['1', "shorten the list to speedup tests\n\t\t'2',\n\t\t'3',\n4"]

JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


More information about the Python-list mailing list