I have a property setter which generates a unique id by taking two strings and hashing it:
@id.setter
def id(self,value1,value2):
self._id = sha512(value
You could use the property() function as well like this.
from hashlib import sha512
class U:
def __init__(self, value1, value2):
self.id_setter(value1, value2)
def id_getter(self):
return self._id
def id_setter(self, value1: str, value2: str):
value1, value2 = value1.encode(), value2.encode()
self._id = sha512(value1+value2)
id = property(id_getter, id_setter) # <----
u = U("Foo", "Bar")
print(u.id.hexdigest())