From f73e2571fb643a2afdde365eeee0fe0f3f4f5300 Mon Sep 17 00:00:00 2001 From: Jon Dufresne Date: Thu, 24 Oct 2019 20:11:14 -0700 Subject: Use pyupgrade to upgrade the code to use Python3 conventions (#138) The pyupgrade project is available at https://github.com/asottile/pyupgrade and can be installed through pip. The pyupgrade tool automatically upgrades syntax for newer versions of the language. As pyparsing is now Python 3 only, can apply some cleanups and simplifications. Ran the tool using the following command: $ find . -name \*.py -exec pyupgrade --py3-plus {} \; For now, pyparsing.py was skipped while it is refactored to a package. --- examples/pythonGrammarParser.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'examples/pythonGrammarParser.py') diff --git a/examples/pythonGrammarParser.py b/examples/pythonGrammarParser.py index 4a8adce..e3685a1 100644 --- a/examples/pythonGrammarParser.py +++ b/examples/pythonGrammarParser.py @@ -130,14 +130,14 @@ testlist1: test (',' test)* encoding_decl: NAME """ -class SemanticGroup(object): +class SemanticGroup: def __init__(self,contents): self.contents = contents while self.contents[-1].__class__ == self.__class__: self.contents = self.contents[:-1] + self.contents[-1].contents def __str__(self): - return "{0}({1})".format(self.label, + return "{}({})".format(self.label, " ".join([isinstance(c,str) and c or str(c) for c in self.contents]) ) class OrList(SemanticGroup): @@ -164,7 +164,7 @@ class Atom(SemanticGroup): self.contents = contents[0] def __str__(self): - return "{0}{1}".format(self.rep, self.contents) + return "{}{}".format(self.rep, self.contents) def makeGroupObject(cls): def groupAction(s,l,t): -- cgit v1.2.1