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.