import mpdclient2, timing, time search_list = list() # ?!?! http://www.faqs.org/docs/diveintopython/regression_filter.html # def get(obj, type, data): if hasattr(obj, type): if getattr(obj, type) == data: search_list.append(obj) timing.start() mpd = mpdclient2.connect(); info = mpd.playlistinfo() for i in range (0, len(info)): get(info[i], "artist", "Beck") # get(info[i], "title", "Hotwax") # get(info[i], "album", "Odelay") timing.finish() print "There are: %d items! (%d seconds)" % (len(search_list), timing.seconds()) # There are: 272 items! (3 seconds)