[Python-ideas] Alternative spelling for list.append()
Michael Selik
mike at selik.org
Mon Jun 18 22:43:34 EDT 2018
On Mon, Jun 18, 2018, 6:59 PM Michael Selik <mike at selik.org> wrote:
>
> if isinstance(v, ParseResults):
> if v:
> s = v.dump(indent, depth + 1)
> else:
> s = _ustr(v)
> else:
> s = repr(v)
> lines.append(fmt % (k, s))
>
On the 2nd thought, that nested if is ugly. Much better as
if not isinstance(v, ParseResults):
s = repr(v)
elif v:
s = v.dump(indent, depth + 1)
else:
s = _ustr(v)
lines.append(fmt % (k, s))
It might seem like this is going off topic. What I'm trying to demonstrate
is that cases where an append operator might help are really in need of
more thorough revision, not just a little sugar.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180618/7fda8552/attachment.html>
More information about the Python-ideas
mailing list