MENU

Fun & Interesting

Do We Still Need Dataclasses? // PYDANTIC Tutorial

ArjanCodes 206,320 4 years ago
Video Not Working? Fix It Now

💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. Pydantic is a very useful package that makes dealing with data much easier, similar to what Python's built-in dataclasses do. Where Pydantic shines is in dealing with validating and sanitizing data. In this tutorial video, I show you how it works, and when to choose Pydantic over dataclasses in your code projects. The code that I worked on in this video is available here: https://github.com/ArjanCodes/2021-pydantic. 🎓 ArjanCodes Courses: https://www.arjancodes.com/courses/ 🔖 Chapters: 0:00 Intro 0:52 Explaining the example 1:54 Creating a Pydantic Basemodel 4:42 Adding field validation 9:47 Adding model-level validation 12:54 More possibilities by adding a Config class 14:03 Converting the model instances to a dictionary 14:38 Other things that Pydantic can do 15:38 So, are dataclasses obsolete? #arjancodes #softwaredesign #python

Comment