diff options
author | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-07-19 01:27:26 -0500 |
---|---|---|
committer | Paul McGuire <ptmcg@users.noreply.github.com> | 2020-07-19 01:27:26 -0500 |
commit | 11cdffe3dff0449d7f49c90aaefb572c01ddb580 (patch) | |
tree | 21223cfbd9868020f4a43b26d19b880f6163378e /pyparsing/results.py | |
parent | 31679fac4fb3811004e5dc09c1465d7117edc830 (diff) | |
download | pyparsing-git-11cdffe3dff0449d7f49c90aaefb572c01ddb580.tar.gz |
Replace last-century '%' string interp with .format() usage
Diffstat (limited to 'pyparsing/results.py')
-rw-r--r-- | pyparsing/results.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/pyparsing/results.py b/pyparsing/results.py index c3fcd2d..cac1a3c 100644 --- a/pyparsing/results.py +++ b/pyparsing/results.py @@ -47,7 +47,7 @@ class ParseResults: result = date_str.parseString("1999/12/31") def test(s, fn=repr): - print("%s -> %s" % (s, fn(eval(s)))) + print("{} -> {}".format(s, fn(eval(s)))) test("list(result)") test("result[0]") test("result['month']") @@ -254,7 +254,9 @@ class ParseResults: if k == "default": args = (args[0], v) else: - raise TypeError("pop() got an unexpected keyword argument '%s'" % k) + raise TypeError( + "pop() got an unexpected keyword argument {!r}".format(k) + ) if isinstance(args[0], int) or len(args) == 1 or args[0] in self: index = args[0] ret = self[index] @@ -395,7 +397,7 @@ class ParseResults: return other + self def __repr__(self): - return "(%s, %s)" % (repr(self._toklist), self.asDict()) + return "({!r}, {})".format(self._toklist, self.asDict()) def __str__(self): return ( @@ -560,7 +562,7 @@ class ParseResults: for k, v in items: if out: out.append(NL) - out.append("%s%s- %s: " % (indent, (" " * _depth), k)) + out.append("{}{}- {}: ".format(indent, (" " * _depth), k)) if isinstance(v, ParseResults): if v: out.append( @@ -580,8 +582,7 @@ class ParseResults: for i, vv in enumerate(v): if isinstance(vv, ParseResults): out.append( - "\n%s%s[%d]:\n%s%s%s" - % ( + "\n{}{}[{}]:\n{}{}{}".format( indent, (" " * (_depth)), i, |