def multihash(obj, *attrs):
    """Generate a hash of the object using the provided attributes.

    31 is a "magic number"; it's the same magic number used by Java
    when hashing multiple objects.
    """
    result = 1
    for attr in attrs:
        result = 31 * result + hash(getattr(obj, attr))
    return result
