Python Safely Navigate a Complex Data Structure

From NovaOrdis Knowledge Base
Revision as of 04:50, 10 March 2022 by Ovidiu (talk | contribs) (→‎Internal)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Internal

Overview

yaml = ...
v = None
first_level_map = yaml.get('first_level_key') 
if first_level_map:
  second_level_map = first_level_map.get('second_level_key')
  if second_level_map:
    v = second_level_map.get('leaf_key')
return v