Skip to content

Instantly share code, notes, and snippets.

@fajran fajran/m.py
Created Jun 9, 2013

Embed
What would you like to do?
Himpunan unik di Python
class M(object):
def __init__(self, posisi, asam_amino):
self.posisi = posisi
self.asam_amino = asam_amino
def __repr__(self):
return "%s%s" % (self.posisi, self.asam_amino)
def __eq__(self, o):
if not isinstance(o, M):
return False
return self.posisi == o.posisi \
and self.asam_amino == o.asam_amino
def __hash__(self):
return hash((self.posisi, self.asam_amino))
mutasi = [ M(1, "a"), M(2, "b"), M(1, "c"), M(3, "b"), M(1, "a") ]
print mutasi
print set(mutasi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.