Do We Still Need Dataclasses? // PYDANTIC Tutorial

Do We Still Need Dataclasses? // PYDANTIC Tutorial

ArjanCodes

3 года назад

201,079 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@dr.mikeybee
@dr.mikeybee - 30.04.2022 08:17

Thanks! Good stuff.

Ответить
@brunosompreee
@brunosompreee - 13.05.2022 20:07

Thanks!

Ответить
@phill4337
@phill4337 - 16.05.2022 02:57

do u have hair implants

Ответить
@climbit9555
@climbit9555 - 20.05.2022 01:07

One little advantage of pydantic is that mutable default arguments are easier to use. I know dataclasses have the field possibility, but that has its limits and is a little ugly.
Also the validation implementation is a lot nicer in the newer versions :)

Ответить
@abteyeb7969
@abteyeb7969 - 27.05.2022 22:44

i dont understood This but u are able in coding thinks

Ответить
@jval7
@jval7 - 03.06.2022 16:51

amazing!

Ответить
@apoorvsrivastava9677
@apoorvsrivastava9677 - 19.06.2022 11:05

bro u look like Ashish Chanchalani look him up 🙂

Ответить
@vitoanania6042
@vitoanania6042 - 19.06.2022 15:06

can you set an order for the objects in pydantic as for dataclasses?

Ответить
@silkogelman
@silkogelman - 06.07.2022 11:27

Thank you so much for this very interesting Pydantic example with both validation levels Arjan! 🙏😀
I'm hoping you'll blend in more Pydantic in your tutorials in the future.
FYI: for the price field you can use Decimal or condecimal with max_digits and decimal_places to more accurately represent money.

Ответить
@benjaminacar4001
@benjaminacar4001 - 19.07.2022 12:47

Thanks to Yann LeCun's little brother for sharing this knowledge.

Ответить
@digitig
@digitig - 24.07.2022 02:08

Of course, in the real world it's annoying that programs dealing with books insist there has to be an ISBN. I have quite a few books from before the introduction of ISBNs (the oldest is from 1711), and I rejected quite a few cataloguing systems because they wouldn't accept some of my books.

Ответить
@machinimaaquinix3178
@machinimaaquinix3178 - 03.08.2022 21:51

Great tutorial, you earned a new sub.

Ответить
@valk9819
@valk9819 - 08.08.2022 01:40

Will we see Pydantic vs Marshmallow?

Ответить
@sinterkaastosti988
@sinterkaastosti988 - 10.08.2022 15:08

ik ruik nederlands

Ответить
@mishmohd
@mishmohd - 10.08.2022 23:16

I thought I knew how to define classes and methods 🥲

Ответить
@HandcartRule46
@HandcartRule46 - 03.10.2022 20:15

Excellent tutorial. More of these please, thank you! :-)

Ответить
@ruizdani3016
@ruizdani3016 - 08.10.2022 05:26

hi, into the documentation where explain about how pydantic type more than 2 dates like return example () -> int, str .....

Ответить
@sukanyar4373
@sukanyar4373 - 24.10.2022 00:32

Excellent tutorial on pydantic ! :) Thank you! :) 🙌

Ответить
@cosmicblack
@cosmicblack - 11.11.2022 23:23

As always, excellent video thanks for the time, i learned something now to implement it

Ответить
@AndreNitschke
@AndreNitschke - 29.11.2022 09:05

When not write a Rest API, why not using attrs instead of pydantic? Is faster and not so resource hungry.

Ответить
@ipelezikis
@ipelezikis - 09.01.2023 03:43

Very interesting stuff. Continue the great work!!

Ответить
@MCRuCr
@MCRuCr - 17.01.2023 17:28

I think if people need to add static type checking to a dynamic language, you are using the wrong language.

Ответить
@alvin_paul
@alvin_paul - 20.01.2023 02:58

You are one of the best if not the best Python Channels that I know of. I am learning a lot from you 😊 Keep up the interesting topics and good work 👍👍👍

Ответить
@slaweksx1564
@slaweksx1564 - 21.01.2023 11:28

Very useful and interesting. Than you Arjan. Small correction to custom exception, there should be inheritance from ValueError. Otherwise FastAPI generates status 500 without Pedantic validation message.

Ответить
@theultimatereductionist7592
@theultimatereductionist7592 - 25.01.2023 07:24

There exist many MANY ideas I would love to code, but I know they are not worth it: no matter in what language I code them.
They are all math ideas. A lot (not all) are coding the solutions to PDEs and ODEs. Some are for papers I wish to publish.
Python is the only language I know, and just barely. Used to know C++, a little Java, and Fortran.

I realize now that the mathematical ideas are simply too complex to be coded.
For example in 2020 I attempted to code computing all infinitely many solutions for a trinomial w=C*z-z^A
where w, C, A are complex numbers. Got close, but there was no way to get roots, z, that are within error limits when plugged back into the trinomial. Had hoped to publish it. But I had to leave it unfinished.
Definitely a HUGE lesson about NOT coding anything deep or complicated:
OTHER than the simplest of calculations, say, with a for loop. In other words, Python is my extension of a handheld calculator.

Ответить
@brahimboughanam1662
@brahimboughanam1662 - 29.01.2023 15:20

oh thank you arjan

Ответить
@berkistayn
@berkistayn - 17.02.2023 15:52

Decent tutorial. However, the title is misleading: I was expecting an in-depth comparison and pros cons with respect to dataclasses in code.

Ответить
@ylazerson
@ylazerson - 20.02.2023 11:28

great video - thanks!

Ответить
@pahvalrehljkov
@pahvalrehljkov - 05.03.2023 17:49

My go to for anything related finishing project. Even as hobby programmer i almost always use your tutorials to make proper code, and in end i remove my bugs from code.

Ответить
@auroraRealms
@auroraRealms - 23.03.2023 00:52

In my opinion (for web service back end programming) Pydantic is the way to go, and then straight into NoSQL, like MongoDB or ElasticSearch. I avoid SQL, Data Classes, and ORM as much as possible. I think SQL is an outdated technology that adds too many problems, complexities, and expenses that do not need to be there. The only case I have for SQL is existing databases, and technologies. When I have a choice, I do not develop any new software using SQL.

Ответить
@simonwochner3708
@simonwochner3708 - 27.03.2023 12:29

Isn't it also possible to validate inputs of dataclasses inside a _post_init_ function? For me no reason to use pydantic.

Ответить
@naderbazyari2
@naderbazyari2 - 29.03.2023 18:59

Thanks a million Arjan for great video. I had a newbie question.
When I changed the order of "@classmethod" and "@pydantic.validator("isbn_10")" the way you suggested(minute 9 video), I did not get the Error. I know the importance of placing decorators in order but I do not understand how come the validation does not take place if I put the "@pydantic.validator("isbn_10")" immediately above the method declaration? it gets overridden?

Ответить
@bluebabboon
@bluebabboon - 08.04.2023 20:39

Bro what is your keyboard? It's so soothng to hear and type i guess?

Ответить
@italo.buitron
@italo.buitron - 09.06.2023 22:22

We need a Guide with Pydantic and ABC or Protocol

Ответить
@cosmic_Robot
@cosmic_Robot - 23.06.2023 05:47

Great video Arjan. Subscribed.

Ответить
- 19.07.2023 02:06

@ArjanCodes I'd love to see an updated version using the new Pydantic v2, your thoughts on it, and how it sits now in the pydanticV2 vs dataclasses p3.11 vs attrs

Ответить
@konstantinosmaravegias4198
@konstantinosmaravegias4198 - 22.10.2023 13:49

I want to thank you from my bottom of my heart! You have made me a better Data professional!

Ответить
@jkrigelman
@jkrigelman - 04.11.2023 00:11

Pydantic's requirement that the values can only be set from dictionaries is a bit annoying. In some cases reading in an array from JSON is good enough to initialize an object. Not sure why it's so inflexible in this.

Ответить
@FullStackWithLawrence
@FullStackWithLawrence - 06.12.2023 02:14

this is helpful, thanks for sharing.

Ответить
@shabnamkoosha
@shabnamkoosha - 10.12.2023 09:44

Thanks!

Ответить
@alexforget
@alexforget - 17.12.2023 20:40

how is he able to type that fast?

Ответить
@louieatkins-turkish1349
@louieatkins-turkish1349 - 29.12.2023 23:27

What is pydantic actually doing in these cases? You can do these checks and raise custom exceptions already without pydantic

Ответить
@RicoRojas
@RicoRojas - 19.02.2024 18:09

any chance you want to update the code for V2?

Ответить
@abraham_o
@abraham_o - 23.05.2024 16:02

Dataclasses wouldn't ignore any additional attribute in the dataset used to initialize an instance of the class, it will always raise an Exception, another beautiful thing about pydantic, pydantic will just ignore any extras. Which comes in very handy when using them to model third-party response for syntax highlighting rather then just relying on dictionaries.

Ответить
@saketkr
@saketkr - 04.06.2024 18:55

I know pydantics better now, thanks. :-)

Ответить
@wuzixiao1
@wuzixiao1 - 10.06.2024 21:58

Another great video. I thought pedantic is just for validation but I know more now. It is great tool to deal with json object like book = [(**list) for list in json]

Ответить
@NatalieMorgan-q9r
@NatalieMorgan-q9r - 28.08.2024 05:00

Moore Eric Gonzalez Jessica Young Ronald

Ответить