101 days ago · 5 min read1053 words · Tech · hide · Fediverse post

Python A-Z is a blog series about Python. Each day, I share insights, ideas and examples for different parts of Python development that match with the letter of the day. Blaugust is an annual blogging festival in August where the goal is to write a blog post every day of the month. When you need to load external data into your software, you want to make sure it behaves properly, ie. it’s in correct form. One tool to validate input data is Pydantic. This is a quick tutorial to show how it works. Installing Pydantic Set up your environment and install with pip install pydantic Alternatively, you can run these with uv: uv run --with pydantic code.py Simplified Pokédex data For this demo, I’m using a simplified data set adapted from Purukitto’s Pokemon.json. I’ve saved this to a file pokedex.json. [ { "id": 1, "name": "Bulbasaur", "type": ["Grass", "Poison"], "stats": { "HP": 45, "Attack": 49, "Defense": 49, "Sp. Attack": 65, "Sp. Defense": 65, "Speed": 45 }, "height": "0.7 m", "weight":…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town