Does hashlib support a file mode?

Anssi Saari as at
Thu Jul 7 13:29:38 CEST 2011

Mel <mwilson at> writes:

> def file_to_hash(path, m = hashlib.md5()):
> hashlib.md5 *is* called once; that is when the def statement is executed.

Very interesting, I certainly wasn't clear on this. So after that def,
the created hashlib object is in the module's scope and can be
accessed via file_to_hash.__defaults__[0].

More information about the Python-list mailing list