Working with APIs in Python? Use Pydantic

preview_player
Показать описание
Thanks for IPRoyal for sponsoring this video! Get 30% off any Royal Residential Proxies by following this link and using code "CARBERRA" at checkout!



A while ago I covered TypedDict in a video and got A LOT of comments talking about how amazing Pydantic is. Turns out they were right, so I thought I'd show it off!



If you enjoy my content, consider supporting me on Patreon or becoming a member!

If you need help with anything, feel free to join the Discord server:

I get a lot of people asking, so here's my Visual Studio Code setup!



If you have any questions, don't hesitate to ask in the comments! I'll try and answer as soon as I can, providing someone else hasn't already done so.

#python #coding #howto
Рекомендации по теме
Комментарии
Автор

Thanks for IPRoyal for sponsoring this video! Get 30% off any Royal Residential Proxies by following this link and using code *"CARBERRA"* at checkout!

Carberra
Автор

To convert the field name, you can use the simplest way. Use 'Field(alias="....")'

from pydantic import BaseModel, Field


class Example(BaseModel):
pythonic_field: str = Field(alias="CamelCaseField")


resp = {"CamelCaseField": "cool"}

p = Example(**resp)
print(p)

antonzimin
Автор

You can make gt, ge etc. validators automatically by using =Field()

IwoGda
Автор

that basemodel class is borrowed from typescript Interfaces

redsolaris
Автор

I wish I had learned this a month ago...

yknukrq