human
Complete this python program:
def _parse_query_string_settings(query_kwargs, settings=None):
assistant
#Here is the Python code you requested.

    """Parse the values in `query_kwargs` from strings to the proper types
    listed in the same key in `settings`.
    """
    def list_from_query_string(s):
        return s.split(',')
    parsers = {'int': int, 'float': float, 'bool': bool, 'list:str': (lambda s: list_from_query_string(s)), 'list:escaped': (lambda s: [unquote(e) for e in list_from_query_string(s)]), 'list:int': (lambda s: [int(i) for i in list_from_query_string(s)])}
    settings = (settings or {})
    for key in settings:
        if (key in query_kwargs):
            query_value = query_kwargs[key]
            needed_type = settings[key]
            if (needed_type != 'str'):
                try:
                    query_kwargs[key] = parsers[needed_type](query_value)
                except (KeyError, ValueError):
                    del query_kwargs[key]
    return query_kwargs