From b5fa3354d0d24440bc13e22fe9170c5a31d348df Mon Sep 17 00:00:00 2001 From: Alexis Roda Date: Fri, 26 Jul 2019 20:40:31 +0200 Subject: Make code more pythonic. --- z80count.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'z80count.py') diff --git a/z80count.py b/z80count.py index 02c75a4..c44a90a 100755 --- a/z80count.py +++ b/z80count.py @@ -79,8 +79,8 @@ def init_table(table_file="z80table.json"): with open(table_file, "rt") as fd: table = json.load(fd) - for i in range(len(table)): - table[i]["cregex"] = re.compile(table[i]["regex"] + r"\s?(;.*)?", re.I) + for i in table: + i["cregex"] = re.compile(i["regex"] + r"\s?(;.*)?", re.I) return sorted(table, key=lambda o: o["w"]) @@ -121,11 +121,7 @@ def main(): out_f = args.outfile table = init_table() total = total_cond = 0 - while True: - line = in_f.readline() - if not line: - break - + for line in in_f: output, total, total_cond = z80count( line, table, total, total_cond, args.subt, args.update, args.tabstop, args.debug) out_f.write(output) -- cgit v1.2.3