From: MRAB on
Steven D'Aprano wrote:
> On Thu, 29 Apr 2010 06:17:42 +1000, Lie Ryan wrote:
>
>>> Consider that the concatenation language feature probably is there
>>> because it's useful (e.g. it preserves indentation and allows per line
>>> comments).
>> No, the implicit concatenation is there because Python didn't always
>> have triple quoted string.
>
> Do you have a source for that?
>
> Both triple-quoted strings and implicit concatenation go back to at least
> Python 1.4:
>
> http://docs.python.org/release/1.4/tut/node71.html
> http://docs.python.org/release/1.4/tut/node70.html
>
The page here:

http://svn.python.org/projects/python/branches/py3k/Misc/HISTORY

says release 1.0.2 (4 May 1994).
From: Steven D'Aprano on
On Thu, 29 Apr 2010 02:16:46 +0100, MRAB wrote:

> Steven D'Aprano wrote:
>> On Thu, 29 Apr 2010 06:17:42 +1000, Lie Ryan wrote:
>>
>>>> Consider that the concatenation language feature probably is there
>>>> because it's useful (e.g. it preserves indentation and allows per
>>>> line comments).
>>> No, the implicit concatenation is there because Python didn't always
>>> have triple quoted string.
>>
>> Do you have a source for that?
>>
>> Both triple-quoted strings and implicit concatenation go back to at
>> least Python 1.4:
>>
>> http://docs.python.org/release/1.4/tut/node71.html
>> http://docs.python.org/release/1.4/tut/node70.html
>>
> The page here:
>
> http://svn.python.org/projects/python/branches/py3k/Misc/HISTORY
>
> says release 1.0.2 (4 May 1994).

Yes, it says:

* String literals follow Standard C rules: they may be continued
on the next line using a backslash; adjacent literals are
concatenated at compile time.

* A new kind of string literals, surrounded by triple quotes
(""" or '''), can be continued on the next line without a
backslash.


These are adjacent entries in the same release. That's pretty good
evidence that both implicit concatenation and triple quotes were
introduced at the same time.



--
Steven
From: Gregory Ewing on
Lie Ryan wrote:
> No, the implicit concatenation is there because Python didn't always
> have triple quoted string. Nowadays it's an artifact and triple quoted
> string is much preferred.

I don't agree. I often use implicit concatenation when I'm
writing a format string that won't fit on one source line,
because it allows me to fit it into the surrounding indentation
structure without introducing unwanted spaces into the string.

Both tecnhiques have their places.

--
Greg
From: goldtech on
Thank you to posters for help to my question. Seems I had trouble with
triple quotes strings in the PythonWin shell. But using the Idle shell
things work as expected. But this is probably another issue...any way,
w/Idle's shell I got the "action" regarding multiline strings I
expected.
From: Lie Ryan on
On 04/29/10 20:40, Gregory Ewing wrote:
> Lie Ryan wrote:
>> No, the implicit concatenation is there because Python didn't always
>> have triple quoted string. Nowadays it's an artifact and triple quoted
>> string is much preferred.
>
> I don't agree. I often use implicit concatenation when I'm
> writing a format string that won't fit on one source line,
> because it allows me to fit it into the surrounding indentation
> structure without introducing unwanted spaces into the string.
>
> Both tecnhiques have their places.
>

That statement should be quantified with "for large chunks of text".
Format string is typically 2-3 lines at most, not enough to qualify as
large chunk.