Re: Multi-line string extension

Donald Beaudry (
Fri, 15 Apr 94 16:00:05 EDT

>>>>> On Fri, 15 Apr 94 15:42:21 -0400, Tim Peters <> said:

>> [don, wanting to ease multi-line strings]
>> ...
>> big_string = \
>> %(
>> this is a really big multi line string that
>> has embedded "double quotes" and 'single quotes'
>> %)
>> the resulting string would be equivalent to
>> big_string = \
>> 'this is a really big multi line string that \n' +\
>> 'has embedded \"double quotes\" and \'single qoutes\''

> This is a little surprising, because your equivalent doesn't have a
> newline at the end of the "has" line (but does at the end of the "this"
> line).

Oops... I really ment to have the trailing newline. Really I did!

> Note that Perl has three syntactically horrific (but pragmatically
> delightful!) variations on the theme, all illustrated in this Perl
> fragment:

[perl code removed]

> Judged by what these mechanisms _do_ and allow, they're just about
> perfect. Or are in the context of Perl <wink>.

>> ... And as an extra bonus, it would generate code that was much more
>> efficient.

> But this point's weak; Python's implementation could be fiddled to
> collapse catenated string literals at translation time, if anyone cared
> enough to bother doing it.

Ok, so the bonus is weak (assuming of course that someone bothers to
make your suggested optimization). But, I have to wonder, do you also
complain when the guy down at EggRoll Express gives you a free bowl of
soup with your Kung Pao Chicken luncheon special.

The point I was trying to make was that it would be nice if you could
enter large amounts of text without having to escape all of your
quotes and paste together a bunch of smaller strings. I certaintly
was not trying to suggest adding all those perl-isms that you
mentioned. After all, Python is a real programming language. But,
based on your comments, I take it that you like the idea :)


______ ______
\_\_\_\ /#/#/#/
\_\_\_\ ______
\_\_\_V#/#/#/ Donald Beaudry
\_\_/#/#/#/ V. I. Corporation uunet!vicorp!don
\_/#/#/#/ 47 Pleasant Street PHONE: (413) 586-4144
V#/#/#/ Northampton, MA 01060 FAX: (413) 586-3805