def flatten_dictionary(input, sep='.', prefix=None):
 for (name, value) in sorted(input.items()):
  fullname = sep.join(filter(None, [prefix, name]))
  if isinstance(value, dict):
   for result in flatten_dictionary(value, sep, fullname):
    (yield result)
  else:
   (yield (fullname, value))

def flatten_dictionary ( input , sep = '.' , prefix = None ) : for ( name , value ) in sorted ( input . items ( ) ) : fullname = sep . join ( filter ( None , [ prefix , name ] ) ) if isinstance ( value , dict ) : for result in flatten_dictionary ( value , sep , fullname ) : ( yield result ) else : ( yield ( fullname , value ) )
produces iterator of pairs where the first value is the joined key names and the second value is the value associated with the lowest level key .