Simpler Python YAML

preview_player
Показать описание
In this video you'll see a better way to handle complex YAML files: instead of using PyYAML we're going to use Mashumaro.

Once you set up the dataclasses, which are special types of Python classes frquently used to hold simple data, this library loads the file content in their instances. These dataclasses can be nested, reflecting the possible complex structures of a YAML file. Integrating this kind of code in Python program to load configurations greatly simplifies data validation and improves code modularity.

Links

CHAPTERS

0:00 Intro
0:37 Using PyYAML gets you a dictionary for free
1:18 Thinking about the YAML file as a "container" of different elements
1:27 Creating the class (dataclass) representing the elements of the list
2:39 Dataclass containing the list
4:02 Another dataclass
4:34 The dataclass containing references to all the other dataclasses: this is the root object of a tree representing the YAML file
5:09 Introducing the Mashumaro library
5:47 Mashumaro's YAML functions
6:07 Reading from YAML
6:33 Running the program
7:21 Printing values from the dataclasses
8:46 Callback function for string validation: checking what happens if we change a value type in the YAML file
9:55 More about dataclasses
10:58 Transform a dataclass instance to a dictionary and do more printings
12:20 Outro

#yaml #python #dataclass #mashumaro #programming
Рекомендации по теме
Комментарии
Автор

But it still uses PyYaml underneath. So it doesn't help me much.

freakent