Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Lawrence D’Oliveiro
On Sunday, August 14, 2016 at 1:53:42 PM UTC+12, John Wong wrote: > s = ("this string continues " + >"substring continues") Now there’s a Java way of doing it. :) I prefer implicit string concatenation myself. Isn’t it peculiar that, while this feature was introduced in C and faithfully

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Steven D'Aprano
On Sun, 14 Aug 2016 11:53 am, John Wong wrote: > The way I solve it, and I still find that extremely ugly, is > > s = ("this string continues " + >"substring continues") You don't need the plus sign, as Python will concatenate string literals (not variables) at compile time: "foo" 'bar'

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread John Wong
On Sat, Aug 13, 2016 at 8:38 PM, Lawrence D’Oliveiro wrote: > Python allows a single string literal to cross multiple lines, provided it > begins and ends with three quote characters, e.g. > > s = """this string continues > on the next line.""" > > There is a drawback with this: any white

Re: Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Ben Finney
Lawrence D’Oliveiro writes: > So really, you should write it more like > > s = """this string continues > on the next line.""" > > which gets a bit ugly. For this I have the following treatment http://stackoverflow.com/a/2504454/70157>: import textwrap s = textwrap.dedent("""\

Multi-Line Strings: A Modest Proposal

2016-08-13 Thread Lawrence D’Oliveiro
Python allows a single string literal to cross multiple lines, provided it begins and ends with three quote characters, e.g. s = """this string continues on the next line.""" There is a drawback with this: any whitespace at the start of the continuation line is included as part of the s