Lists And Missing Commas
Frank Millman
frank at chagford.com
Tue Dec 24 00:46:00 EST 2019
On 2019-12-24 6:20 AM, Tim Daneliuk wrote:
> On 12/23/19 7:52 PM, DL Neil wrote:
>>
>> WebRef: https://docs.python.org/3/reference/lexical_analysis.html
>
>
> Yep, that explains it, but it still feels non-regular to me. From a pointy headed academic
> POV, I'd like to see behavior consistent across types. Again ... what do I know?
>
From the Zen, 'Practicality beats purity'.
From the docs -
"""
String literals that are part of a single expression and have only
whitespace between them will be implicitly converted to a single string
literal. That is, ("spam " "eggs") == "spam eggs".
"""
I do not see it as 'concatenation', rather as a way of constructing a
single string from a number of smaller chunks. The docs talk about
'whitespace', but I would guess that the use of a single space is
uncommon. More likely is the use of a newline.
I use this from time to time when constructing long string literals -
long_string = (
"this is the first chunk "
"this is the second chunk "
"etc etc"
)
My 0.02c
Frank Millman
More information about the Python-list
mailing list