On 2020-06-17 12:46 p.m., Christopher Barker wrote:
On Wed, Jun 17, 2020 at 6:09 AM Soni L. <fakedme...@gmail.com
<mailto:fakedme%2...@gmail.com>> wrote:
This also gives us two ways of doing indented strings (in Lua):
local ugly = "foo\n \z
bar\n \z
baz"
local nicer = "foo\n\z
\x20 bar\n\z
\x20 baz"
I'm having a really hard time seeing why that is either more readable,
or easier to type than:
nicest = ("foo"
" bar"
" baz"
)
(my prefered way these days)
I think you missed some \n's here.
or
nicest = \
"""foo
bar"
baz"""
this is ugly. what's wrong with textwrap.dedent?
however, I bring up again the original use-case which has nothing to do
with textwrap.dedent, or nested indentation. But consider this
artificial example:
foo = textwrap.dedent("""
This is the help page for foo, a command \z
with the following subcommands:
bar - A very useful subcommand of foo \z
and probably the subcommand you'll \z
be using the most.
baz - A simple maintenance command \z
that you may need to use sometimes.
""")
Currently you'd have to write it as:
foo = (
"This is the help page for foo, a command "
"with the following subcommands:\n"
" bar - A very useful subcommand of foo "
"and probably the subcommand you'll "
"be using the most.\n"
" baz - A simple maintenance command "
"that you may need to use sometimes."
)
or if you want it to look "nicer", and don't mind linters shouting at you:
foo = (
"This is the help page for foo, a command "
"with the following subcommands:\n"
" bar - A very useful subcommand of foo "
"and probably the subcommand you'll "
"be using the most.\n"
" baz - A simple maintenance command "
"that you may need to use sometimes."
)
And I think this sucks.
-CHB
--
Christopher Barker, PhD
Python Language Consulting
- Teaching
- Scientific Software Development
- Desktop GUI and Web Development
- wxPython, numpy, scipy, Cython
_______________________________________________
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/C2UFAEH2JUH7LUEL7TSVEO3ISTQSKSP2/
Code of Conduct: http://python.org/psf/codeofconduct/