Weirdness comparing strings
- From: Mr.SpOOn <mr.spoon21@xxxxxxxxx>
- Date: Tue, 30 Sep 2008 12:45:27 +0200
Hi,
I have this piece of code:
class Note():
...
...
def has_the_same_name(self, note):
return self == note
def __str__(self):
return self.note_name + accidentals[self.accidentals]
__repr__ = __str__
if __name__ == '__main__':
n = Note('B')
n2 = Note('B')
print n
print n2
print n.has_the_same_name(n2)
I'd expect to get "True", because their string representation is
actually the same, instead the output is:
B
B
False
I think I'm missing something stupid. Where am I wrong?
.
- Prev by Date: Shed Skin (restricted) Python-to-C++ compiler 0.0.29
- Next by Date: Re: Weirdness comparing strings
- Previous by thread: Shed Skin (restricted) Python-to-C++ compiler 0.0.29
- Next by thread: Re: Weirdness comparing strings
- Index(es):