Skip to content

Instantly share code, notes, and snippets.

@fajran
Created June 9, 2013 19:27
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save fajran/5744836 to your computer and use it in GitHub Desktop.
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