import state import itemname file = open('properties.diff', 'r') for line in file: if line.startswith("typeID: "): line = line.strip() id = int(line.replace("typeID: ", "") )) id = itemname.state()[id] output = "Item:", id if line.startswith(" attribute["): line = line.strip() if line.endswith(")"): l = line.replace("attribute[", "") attribute, values = l.split("]") new, old = values.replace(" = ", "").replace(")", "").split(" (") output += " attribute: %s old value: %s new value: %s" % ( state.state[int(attribute)] , new, old) print output