Skip to content

Instantly share code, notes, and snippets.

@elena-roff
Created March 12, 2019 13:24
Show Gist options
  • Save elena-roff/0e5cc0d8a12a791d10f8b87392474b7b to your computer and use it in GitHub Desktop.
Save elena-roff/0e5cc0d8a12a791d10f8b87392474b7b to your computer and use it in GitHub Desktop.
Creates a hash for an object
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