-
-
Save fajran/5744836 to your computer and use it in GitHub Desktop.
Himpunan unik di Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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