From 3c5c94bc0ede813d97f044c4a7cd84c53e712311 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Fri, 30 Apr 2010 07:39:44 +0200 Subject: song: implement __contains__() --- nephilim/song.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nephilim/song.py b/nephilim/song.py index 6d8cc39..f322fa4 100644 --- a/nephilim/song.py +++ b/nephilim/song.py @@ -63,6 +63,15 @@ class Song(dict): return self['artist'] return '' + def __contains__(self, item): + if dict.__contains__(self, item): + return True + try: + self[item] + return True + except KeyError: + return False + def __nonzero__(self): return bool(self['file']) -- cgit v1.2.3