You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All your samples explain easily if you consider that two adjacent string
literals are joined together. (You seem to consider that "double quote"
is a way to insert a quote character. It's not; Python is not Pascal or
SQL)
Your first two examples become:
a='a''a' two adjacent strings == 'aa'
a='a''''a' three adjacent strings ('a' + '' + 'a') == 'aa'
The third is an error:
a='a''''''a' one string ('a') followed by the beginning of a "triple
quoted string" (''') which content starts with the characters (''a') but
does not have a matching (''') to finish the string, hence the Syntax
error.
Activity
cliffdover88 commentedon Oct 21, 2008
Hi
I have a problem with python 2.6, when i try to process strings with
triple-quoted string literal i get an error:
a... #7 error..................
amauryfa commentedon Oct 21, 2008
All your samples explain easily if you consider that two adjacent string
literals are joined together. (You seem to consider that "double quote"
is a way to insert a quote character. It's not; Python is not Pascal or
SQL)
Your first two examples become:
a='a''a' two adjacent strings == 'aa'
a='a''''a' three adjacent strings ('a' + '' + 'a') == 'aa'
The third is an error:
a='a''''''a' one string ('a') followed by the beginning of a "triple
quoted string" (''') which content starts with the characters (''a') but
does not have a matching (''') to finish the string, hence the Syntax
error.
... and so on. Please have a look at http://docs.python.org/reference/lexical_analysis.html#string-literals