import hashlib


def file_checksum(fname):
    """
    calculates the md5 checksum of a file and returns it as hex string (0-f).
    warning: reads the entire file into memory. see https://stackoverflow.com/a/3431835
    in case you need a memory-efficient variant...
    """
    return hashlib.md5(open(fname, 'rb').read()).hexdigest()