def _filter (self, tag, func):
        """Remove and return matching messages from mailbox and retain the rest.
        """
        mbox = []
        for t in self.mbox:
            if fnmatch.fnmatch(t[2], tag) and func(t):
                yield t
            else:
                mbox.append(t)
        self.mbox = mbox
Remove and return matching messages from mailbox and retain the rest.
        
recipes/Python/577001_sqlite_message_bus/recipe-577001.py