Skip to content

Instantly share code, notes, and snippets.

@zsoldosp
Last active September 25, 2015 20:43
Show Gist options
  • Save zsoldosp/da7132ecadfd880aa2c2 to your computer and use it in GitHub Desktop.
Save zsoldosp/da7132ecadfd880aa2c2 to your computer and use it in GitHub Desktop.
avoiding duplication in yaml files. Heard about from @beerops https://twitter.com/beerops/status/647499854499987456 then googled and found https://gist.github.com/bowsersenior/979804
default: &DEFAULT
URL: stooges.com
throw_pies?: true
stooges: &stooge_list
larry: first_stooge
moe: second_stooge
curly: third_stooge
development:
<<: *DEFAULT
URL: stooges.local
stooges:
shemp: fourth_stooge
test:
<<: *DEFAULT
URL: test.stooges.qa
stooges:
<<: *stooge_list
shemp: fourth_stooge
import os
import pprint
import yaml # https://pypi.python.org/pypi/PyYAML
file_path = os.path.join(os.path.dirname(__file__), 'data.yml')
with open(file_path, 'r') as f:
yaml_data = f.read()
parsed_data = yaml.load(yaml_data)
pprint.pprint(parsed_data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment