def __init__(self, path, mode, hashtype='sha256'): self.fd = open(path, mode) self.hashtype = hashtype self.hash = hashlib.new(hashtype) self.length = 0