The most common way to split a string in lines is using this concatenation formula.
The most common way to split a string in lines is using this concatenation formula.
Preventing a bug that occurs in 5% of observed codebases (and anecdotally, happens to me during development all the time) seems like about as good as reasons get.
Swapping a perfectly fine print statement for a function, on the other hand… that’s the breaking change in Py3k that’s never seemed worth it to me.
2to3 could also trivially add +, and if anything, that would actually help surface these kind of bugs, because if you randomly see a + in the middle of your list of strings, it's much easier to spot the bug than if there was a missing comma.
Is it really? I tend to avoid it in favour of ””” or ‘\n’.join(<list of lines>), because it looks like a mistake.
Triple quotes are kind of annoying if the string is indented, but you can just not indent the string to avoid the whitespace.
https://docs.python.org/3/library/textwrap.html#textwrap.ded...
or inspect.cleandoc.
https://docs.python.org/3.8/library/inspect.html#inspect.cle...
No footgun potential, and as others have mentioned the “good usage” would often be bad simply because it ends up looking like a mistake even if it’s intentional.