Untitled
unknown
plain_text
2 years ago
741 B
4
Indexable
import hashlib class ProductImage: def __init__(self, color, source, product_id): self.id = hashlib.md5(f"{product_id}_{source}".encode("utf-8")).hexdigest(), self.color = color self.source = source self.product_id = product_id def __eq__(self, other): return self.id == other.id def __hash__(self): return hash(self.id) if __name__ == "__main__": p = ProductImage(color='rgba(235, 185, 176, 1)', source='https://shopdunk.com/images/thumbs/0000704_pink_550.webp', product_id='c96fec4babc128f3088a3f1d3380ad81') print(p.id) # why it return tuple? print(hashlib.md5(f"{p.product_id}_{p.source}".encode("utf-8")).hexdigest())
Editor is loading...