On Mon, Jun 18, 2018, 6:59 PM Michael Selik <m...@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.

>
_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
https://mail.python.org/mailman/listinfo/python-ideas
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to