Комментарии:
Thanks! Good stuff.
ОтветитьThanks!
Ответитьdo u have hair implants
Ответить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 :)
i dont understood This but u are able in coding thinks
Ответитьamazing!
Ответитьbro u look like Ashish Chanchalani look him up 🙂
Ответитьcan you set an order for the objects in pydantic as for dataclasses?
Ответить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.
Thanks to Yann LeCun's little brother for sharing this knowledge.
Ответить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.
ОтветитьGreat tutorial, you earned a new sub.
ОтветитьWill we see Pydantic vs Marshmallow?
Ответитьik ruik nederlands
ОтветитьI thought I knew how to define classes and methods 🥲
ОтветитьExcellent tutorial. More of these please, thank you! :-)
Ответитьhi, into the documentation where explain about how pydantic type more than 2 dates like return example () -> int, str .....
ОтветитьExcellent tutorial on pydantic ! :) Thank you! :) 🙌
ОтветитьAs always, excellent video thanks for the time, i learned something now to implement it
ОтветитьWhen not write a Rest API, why not using attrs instead of pydantic? Is faster and not so resource hungry.
ОтветитьVery interesting stuff. Continue the great work!!
ОтветитьI think if people need to add static type checking to a dynamic language, you are using the wrong language.
Ответить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 👍👍👍
Ответить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.
Ответить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.
oh thank you arjan
ОтветитьDecent tutorial. However, the title is misleading: I was expecting an in-depth comparison and pros cons with respect to dataclasses in code.
Ответитьgreat video - thanks!
Ответить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.
Ответить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.
ОтветитьIsn't it also possible to validate inputs of dataclasses inside a _post_init_ function? For me no reason to use pydantic.
Ответить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?
Bro what is your keyboard? It's so soothng to hear and type i guess?
ОтветитьWe need a Guide with Pydantic and ABC or Protocol
ОтветитьGreat video Arjan. Subscribed.
Ответить@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
ОтветитьI want to thank you from my bottom of my heart! You have made me a better Data professional!
Ответить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.
Ответитьthis is helpful, thanks for sharing.
ОтветитьThanks!
Ответитьhow is he able to type that fast?
ОтветитьWhat is pydantic actually doing in these cases? You can do these checks and raise custom exceptions already without pydantic
Ответитьany chance you want to update the code for V2?
Ответить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.
ОтветитьI know pydantics better now, thanks. :-)
Ответить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]
ОтветитьMoore Eric Gonzalez Jessica Young Ronald
Ответить