Using YAML for configuration files
Python offers a variety of ways to package application inputs and configuration files. We'll look at writing files in YAML notation because this format is elegant and simple.
It can be helpful to represent configuration details in YAML notation.
Getting ready
Python doesn't have a YAML parser built in. We'll need to add the pyyaml
project to our library using the pip
package management system. Here's what the installation looks like:
(cookbook) slott@MacBookPro-SLott Modern-Python-Cookbook-Second-Edition % python -m pip install pyyaml
Collecting pyyaml
Downloading https://files.pythonhosted.org/packages/64/c2/b80047c7ac2478f9501676c988a5411ed5572f35d1beff9cae07d321512c/PyYAML-5.3.1.tar.gz (269kB)
|██████████████████████████&...