def filter_objlist(olist, fieldname, fieldval):
    """
    Returns a list with of the objetcts in olist that have a fieldname valued as fieldval

    @param olist: list of objects
    @param fieldname: string
    @param fieldval: anything

    @return: list of objets
    """
    return [x for x in olist if getattr(x, fieldname) == fieldval]