def incr(fname):
    fhandle = open(fname, 'r+')
    current = int(fhandle.readline(), 16)
    print(current)
    current = current + 1
    fhandle.seek(0)
    fhandle.write(str(format(current, 'x')))
    fhandle.truncate()
    fhandle.close()
    return current
Open a file read an integer from the first line.
dataset/ETHPy150Open EricssonResearch/calvin-base/calvin/utilities/certificate.py/incr