Does hashlib support a file mode?

Phlip phlip2005 at
Thu Jul 7 23:26:56 EDT 2011

> I worded that poorly. None is (AFAIK) the only instance of NoneType, but
> I should've clarified the difference.> The is operator does not compare types, it compares instances for identity.

None is typesafe, because it's strongly typed.

However, what's even MORE X-safe (for various values of X) is a method
that takes LESS for its arguments. That's why I switched from passing
an object to passing a type, because the more restrictive argument
type is more typesafe.

However, the MOST X-safe version so far simply passes a string, and
uses hashlib the way it designs to be used:

def file_to_hash(path, hash_type):

    hash =

    with open(path, 'rb') as f:

        while True:
            s =
            if not s:  break

    return hash.hexdigest()

More information about the Python-list mailing list