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

Igor Korot ikorot01 at gmail.com
Wed Mar 18 14:45:12 EDT 2015


 Hi,

On Wed, Mar 18, 2015 at 2:23 PM, Aditya Raj Bhatt
<adityarajbhatt at gmail.com> wrote:
> On Wednesday, March 18, 2015 at 1:04:39 PM UTC-5, Laurent Pointal wrote:
>> > Can someone also provide a sort of a 'guide' to triple-quoted
> comments
>> > in general?
>>
>> A triple ' or " string is a Python string, allowing line-return in
> string.
>
> What do you mean by line-return in string? Is it newline? Does it mean I
> can write -
>
> '''first part
> second part'''
>
> ?
>
>> If it is in an expression (like a = 5 '''a comment'''), then it must
> be a
>> valid expression (and here it is not).
>
> What is not a valid expression here?

a = 5 #Valid expression
b = c + d # Valid expression
a = 5 b = c + d # Invalid expression

a = 5 # Valid expression
''' testing comment ''' # Valid expression
a = 5 ''' testing comment ''' #Invalid expression

Thank you.
>
>><snip>
>> A+
>> Laurent.
>
> Thank you for the fast and detailed response,
> Aditya
> --
> https://mail.python.org/mailman/listinfo/python-list



More information about the Python-list mailing list