Browse files

Add __richcmp__ for Track, inspired by patch from Per Åstrand.

  • Loading branch information...
1 parent 3673f01 commit 7e7038e4ef6a9f9689f0660f842f2c817ac320ea jorgenpt committed Feb 6, 2010
Showing with 294 additions and 180 deletions.
  1. +286 −180 src/bindings/python/src/spytify.c
  2. +8 −0 src/bindings/python/src/track.pxi
View
466 src/bindings/python/src/spytify.c
286 additions, 180 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
8 src/bindings/python/src/track.pxi
@@ -51,5 +51,13 @@ cdef class Track(SpotifyObject):
def __get__(self):
return self.data.popularity
+ def __richcmp__(Track self, Track other, int operator):
+ if not isinstance(other, Track):
+ return NotImplemented
+ if operator == 2:
+ return self.data.track_id == other.data.track_id
+ else:
+ return NotImplemented
+
def __repr__(self):
return '<Track: %s - %s - %s (%s)>' % (", ".join([a.name for a in self.artists]), self.title, self.album, self.track_id)

0 comments on commit 7e7038e

Please sign in to comment.