def lookup(self, query=''):
        """looks up all contacts where name or address match query"""
        res = []
        query = re.compile('.*%s.*' % re.escape(query), self.reflags)
        for name, email in self.get_contacts():
            if query.match(name) or query.match(email):
                res.append((name, email))
        return res
def lookup ( self , query = '' ) : res = [ ] query = re . compile ( '.*%s.*' % re . escape ( query ) , self . reflags ) for name , email in self . get_contacts ( ) : if query . match ( name ) or query . match ( email ) : res . append ( ( name , email ) ) return res
looks up all contacts where name or address match query