Hello, On Tue, 16 Jun 2020 14:37:39 +0900 "Stephen J. Turnbull" <turnbull.stephen...@u.tsukuba.ac.jp> wrote:
> Soni L. writes: > > > so I propose a \z string escape which lets me write the above as > > shown below: > > > > """switches to toml config format. the old > > 'repos' \z table is preserved as 'repos_old'""" > > We already have that, if you don't care about left-alignment: > > >>> """123456789\ > ... abcdefghi""" > '123456789abcdefghi' > >>> And if you care about left-alignment, but don't care about extra function call, we have https://docs.python.org/3/library/textwrap.html#textwrap.dedent That said, Java (version 13) puts Python to shame with its multi-line strings, which work "as expected" re: leading indentation out of the box: https://openjdk.java.net/jeps/355 . So, I wouldn't "boo, hiss" someone proposing something like: s = _""" Just imagine, this works like you would expect! """ But my response would be my usual - what Python actually needs is macro/AST preprocessing capability, e.g. support for handling '<any_char>"""' strings in user-defined manner. But we can ship some predefined macros, sure. E.g. '_' as a string prefix (like above) would run a string thru (analog of) textwrap.dedent(). -- Best regards, Paul mailto:pmis...@gmail.com _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/EHI3BSDATTH6YHNTZ3BZQBBLPO7VOIBJ/ Code of Conduct: http://python.org/psf/codeofconduct/