Working with APIs in Python? Use Pydantic

Поделиться
HTML-код
  • Опубликовано: 11 сен 2024
  • Thanks for IPRoyal for sponsoring this video! Get 30% off any Royal Residential Proxies by following this link and using code "CARBERRA" at checkout!
    iproyal.club/c...
    -
    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!
    patreon.carber...
    join.carberra.xyz
    If you need help with anything, feel free to join the Discord server:
    discord.carber...
    I get a lot of people asking, so here's my Visual Studio Code setup!
    • My Visual Studio Code ...
    -
    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

Комментарии • 10

  • @Carberra
    @Carberra  Год назад +1

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

  • @antonzimin3999
    @antonzimin3999 Год назад +2

    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)

    • @parikshitrao2948
      @parikshitrao2948 Год назад

      Honestly this looks like you have to do this for every field but here its generalised, if the data keys are less then it would be fine but if you have a lot of keys, its a headache

  • @IwoGda
    @IwoGda 11 месяцев назад

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

  • @redsolaris1
    @redsolaris1 Год назад

    that basemodel class is borrowed from typescript Interfaces

  • @user-yk5nu4kr3q
    @user-yk5nu4kr3q Год назад

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

  • @labret4250
    @labret4250 Год назад +1

    ngl some things are just op

  • @helish_88
    @helish_88 Год назад +1

    Interesting, I miss ur hairs 😢

    • @Carberra
      @Carberra  Год назад +1

      Maybe it'll make a return one day!

    • @helish_88
      @helish_88 Год назад

      @@Carberra