<div dir="ltr">Hi,<br><br>Better post complete code. I don't see where self.note_name is <br>defined, and what are these accidentals?<br><br>you write:<br>def has_the_same_name(self, note):<br>
     return self == note<br><br>but this does not implicitly convert self to a string. You'll have to<br>do in explicitly:<br>use "return str(self) == note" instead.<br><br>Hope this helps,<br>Almar<br><br>
<br><div class="gmail_quote">2008/9/30 Mr. SpOOn <span dir="ltr"><<a href="mailto:mr.spoon21@gmail.com">mr.spoon21@gmail.com</a>></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hi,<br>
I have this piece of code:<br>
<br>
class Note():<br>
      ...<br>
      ...<br>
     def has_the_same_name(self, note):<br>
         return self == note<br>
<br>
     def __str__(self):<br>
         return self.note_name + accidentals[self.accidentals]<br>
<br>
     __repr__ = __str__<br>
<br>
 if __name__  == '__main__':<br>
     n = Note('B')<br>
     n2 = Note('B')<br>
     print n<br>
     print n2<br>
     print n.has_the_same_name(n2)<br>
<br>
I'd expect to get "True", because their string representation is<br>
actually the same, instead the output is:<br>
<br>
B<br>
B<br>
False<br>
<br>
I think I'm missing something stupid. Where am I wrong?<br>
<font color="#888888">--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</font></blockquote></div><br></div>