def flatten_dict(dct, separator='-->', allowed_types=[int, float, bool]):
    """Returns a list of string identifiers for each element in dct.

    Recursively scans through dct and finds every element whose type is in
    allowed_types and adds a string indentifier for it.

    eg:
    dct = {
            'a': 'a string',
            'b': {
                'c': 1.0,
                'd': True
            }
          }
    flatten_dict(dct) would return
    ['a', 'b-->c', 'b-->d']
    """
    flat_list = []
    for key in sorted(dct):
        if key[:2] == '__':
            continue
        key_type = type(dct[key])
        if key_type in allowed_types:
            flat_list.append(str(key))
        elif key_type is dict:
            sub_list = flatten_dict(dct[key])
            sub_list = [str(key) + separator + sl for sl in sub_list]
            flat_list += sub_list

    return flat_list
def flatten_dict ( dct , separator = '-->' , allowed_types = [ int , float , bool ] ) : flat_list = [ ] for key in sorted ( dct ) : if key [ : 2 ] == '__' : continue key_type = type ( dct [ key ] ) if key_type in allowed_types : flat_list . append ( str ( key ) ) elif key_type is dict : sub_list = flatten_dict ( dct [ key ] ) sub_list = [ str ( key ) + separator + sl for sl in sub_list ] flat_list += sub_list return flat_list
Returns a list of string identifiers for each element in dct.

    Recursively scans through dct and finds every element whose type is in
    allowed_types and adds a string indentifier for it.

    eg:
    dct = {
            'a': 'a string',
            'b': {
                'c': 1.0,
                'd': True
            }
          }
    flatten_dict(dct) would return
    ['a', 'b-->c', 'b-->d']