Simpler Python YAML

Опубликовано: 27 Январь 2024
на канале: Solve Computer Science
72
1

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

- original blog post: https://blog.franco.net.eu.org/post/s...
- Mashumaro: https://github.com/Fatal1ty/mashumaro
- Dataclasses: https://docs.python.org/3/library/dat...

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


На этой странице сайта вы можете посмотреть видео онлайн Simpler Python YAML длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Solve Computer Science 27 Январь 2024, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 72 раз и оно понравилось 1 зрителям. Приятного просмотра!