def pprint_dict_in_order(dictionary, order=None):
 order = (order or ())
 def prettyprint(title, body):
  print_info('\n{}:'.format(title.capitalize()))
  if (not isinstance(body, str)):
   for value_element in value:
    print_info('- ', value_element)
  else:
   print_info(value)
 keys = dictionary.keys()
 for element in order:
  try:
   key = keys.pop(keys.index(element))
   value = dictionary[key]
  except (KeyError, ValueError):
   pass
  else:
   prettyprint(element, value)
 for rest_keys in keys:
  prettyprint(rest_keys, dictionary[rest_keys])

def pprint_dict_in_order ( dictionary , order = None ) : order = ( order or ( ) ) def prettyprint ( title , body ) : print_info ( '\n{}:' . format ( title . capitalize ( ) ) ) if ( not isinstance ( body , str ) ) : for value_element in value : print_info ( '- ' , value_element ) else : print_info ( value ) keys = dictionary . keys ( ) for element in order : try : key = keys . pop ( keys . index ( element ) ) value = dictionary [ key ] except ( KeyError , ValueError ) : pass else : prettyprint ( element , value ) for rest_keys in keys : prettyprint ( rest_keys , dictionary [ rest_keys ] )
pretty dict print .