
On 3/31/2018 2:14 PM, Marius Räsener wrote:
Oh, ok... yeah didn‘t think of that. Except I guess I‘d assume that so far multiline strings are either with textwrap or ‚don‘t care‘? Maybe?
For docstrings, I don't care, as a docstring consumer like help() can reformat the docstring with indents and dedents. For instance
def f(): def g(): """returnx
more doc """ print( g.__doc__) help(g)
f() returnx
more doc Help on function g in module __main__: g() returnx more doc For other situations, parse-time string concatenation often suffices, as I showed in my response to the original post. This example from idlelib.config shows the increased flexibility it allows. It has 1-line padding above and 1-space padding to the left to look better when displayed in a popup box. warning = ('\n Warning: config.py - IdleConf.GetOption -\n' ' problem retrieving configuration option %r\n' ' from section %r.\n' ' returning default value: %r' % (option, section, default)) With no padding, I would not argue with someone who prefers textwrap.dedent, but dedent cannot add the leading space. For literals with really long lines, where the physical indent would push line lengths over 80, I remove physical indents. class TestClass(unittest.TestCase): \ test_outputter(self): expected = '''\ First line of a really, really, ............................, long line. Short line. Summary line that utilizes most of the room alloted, with no waste. ''' self.assertEqual(outputter('test'), expected) -- Terry Jan Reedy