code: def read_yaml(file_path, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
      '''Read YAML file and return as python dictionary'''
      # http://stackoverflow.com/a/21912744/943773
  
      class OrderedLoader(Loader):
          pass
  
      def construct_mapping(loader, node):
          loader.flatten_mapping(node)
          return object_pairs_hook(loader.construct_pairs(node))
  
      OrderedLoader.add_constructor(
          yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
          construct_mapping)
  
      with open(file_path, 'r') as f:
  
          return yaml.load(f, OrderedLoaderf read_yaml(file_path, Loader=yaml.Loader, object_pairs_hook=OrderedDict):
      '''Read YAML file and return as python dictionary'''
      # http://stackoverflow.com/a/21912744/943773
  
      class OrderedLoader(Loader):
          pass
  
      def construct_mapping(loader, node):
          loader.flatten_mapping(node)
          return object_pairs_hook(loader.construct_pairs(node))
  
      OrderedLoader.add_constructor(
          yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
          construct_mapping)
  
      with open(file_path, 'r') as f:
  
          return yaml.load(f, OrderedLoader)
docs: Read YAML file and return as python dictionary