title: python3 get nested dictionary/property from yaml file
body: <p>I try to figure out how to get nested data as dictionary/property from yaml file.</p>
  
  <p>The code below works if I provide the function with only one level.
  example : </p>
  
  <pre><code>result = parse_yaml_file(config_yaml_file, 'section')
  </code></pre>
  
  <p>but fails if I try something like :</p>
  
  <pre><code>result = parse_yaml_file(yaml_file, 'section.sub-section')
  </code></pre>
  
  <p>or</p>
  
  <pre><code>result = parse_yaml_file(yaml_file, '[\'section\'][\'sub-section\']')
  </code></pre>
  
  <p>python3 code :</p>
  
  <pre><code>def parse_yaml_file(yml_file, section):
      print('section : ' + section)
      data_dict = {}
      try:
          with open(yml_file) as f:
              data_dict = (yaml.load(f))
      except (FileNotFoundError, IOError):
          exit_with_error('Issue finding/opening ' + yml_file)
  
      if not section:
          return data_dict
      else: 
          return data_dict.get(section)
  
  result = parse_yaml_file(yaml_file, 'section.sub-section.property')
  print(json.dumps(result, indent=4))
  </code></pre>
  
  <p>Is it possible to parse only on part/section of the yaml file ?
  Or just retrieve one sub-section/property from the parsed result ?</p>
  
  <p>I know I can get it from the dictionary like :</p>
  
  <pre><code>data_dict['section']['sub-section']['property']
  </code></pre>
  
  <p>but I want it to be flexible, and not hardcoded since the data to grab is provided as argument to the function.</p>
  
  <p>Thanks a lot for your help.</p>