Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
| Download
Project: Public Code
Views: 852
Kernel: Unknown Kernel
s = {1,3,4,5} s
{1, 3, 4, 5}
s.add(6) s
{1, 3, 4, 5, 6}
s.add(3) s
{1, 3, 4, 5, 6}
s = {"blabla", "blou"}
s
{'blabla', 'blou'}
ch = "blabla" ch
'blabla'
ch.__hash__()
2122255220
class monObjet: def __init__(self): self.value = 0 def __repr__(self): return str(self.value) def __hash__(self): return self.value def __equal__(self, other): if isinstance(other, monObjet) and other.value == self.value: return True return False
o = monObjet() print o
0
s = set() s.add(o) s
{0}
o in s
False
o
4
o.value = 4
s
{4}
s.add(o)
s
{4, 4}