Created
March 12, 2019 13:24
-
-
Save elena-roff/0e5cc0d8a12a791d10f8b87392474b7b to your computer and use it in GitHub Desktop.
Creates a hash for an object
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import hashlib | |
def get_obj_key(obj: Type) -> str: | |
""" Creates and returns a unique object id.""" | |
obj_key = '+'.join( | |
[ | |
obj.attr1, str(obj.num_attr1), obj.attr2, ... | |
]) | |
return hashlib.md5(obj_key.encode('utf8')).hexdigest() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment