def remove_items(headers, condition):
 removed = {}
 keys = filter(condition, headers)
 removed.update(((key, headers.pop(key)) for key in keys))
 return removed

def remove_items ( headers , condition ) : removed = { } keys = filter ( condition , headers ) removed . update ( ( ( key , headers . pop ( key ) ) for key in keys ) ) return removed
remove items matching query from lib .