Python dataclasses will save you HOURS, also featuring attrs

preview_player
Показать описание
Get rid of boilerplate writing classes using dataclasses!

In this video we learn about dataclasses and how to use them, as well as the related attrs library that dataclasses were based on.

Note: As of Python 3.10 dataclasses DO support slots.

SUPPORT ME ⭐
---------------------------------------------------

BE ACTIVE IN MY COMMUNITY 😄
---------------------------------------------------
Рекомендации по теме
Комментарии
Автор

A "Production Python Code" course by you would be a hit. These are the things I never picked up as a mostly self taught programmer. Great stuff.

patrickjdarrow
Автор

I love that you show WHY you would want to use this rather than just what it is. It really drives home the actual usefulness of this

eoghainlebioda
Автор

Update: as of python 3.10, slots are now supported in in-built dataclasses with the ``slots`` argument

octopirate-bak
Автор

Thank you for this valuable video! Before watching your video, I assumed dataclasses were just a Python version of C structs, for cases where you didn't want to add functions in a class but didn't want a raw tuple either. After watching your video, I learned that dataclasses are much more sophisticated than that.

zishiwu
Автор

I'll remember this. I don't know much about OOP so I didn't understand much. When I'll learn, I'll re-watch this video.

usharma
Автор

I have been looking for such tutorials (unique less known concepts for intermediate programmers) for years now. This channel is an absolute gem!
Great work James!

dhanushkari
Автор

I love the way you start by explaining and go to the solutions. Most people just start by showing what it does and how to do it, without ever mentioning why we really need it. Keep going, your style of teaching will reach millions of people.

vnpikachu
Автор

I don't think my jaw has ever dropped from a coding video before. The beauty of being an engineer is you learn something new every day. So much hidden utility in python its amazing!

DSCuber
Автор

Best Python videos on youtube. Or maybe most valuable? Covering so many useful and unique topics no one else seems to.

nicke
Автор

This is actually one of the best CS-related channels I've watched

addvert_br
Автор

Cool functionality. Thanks for sharing
@ 3:32 the dead pan to the camera... Lol !
Love the dry humor

grahamjoss
Автор

As someone who has been slowly getting into the nitty gritty of writing classes, this video was informative, scary, and then relieving. Not only have you showed me what I have yet to learn, but also why it's something that should understood, but hopefully never written.

xavierdingeldein
Автор

Wow, this is an outstanding video! Thank you so much. I just found out you’ve got a Python course, I’m in

mrdbourke
Автор

I'm starting to realize how damn useful class and method decorators are. I have the cumbersome Learning Python book by Orielly but these videos offer a lot of value due to how terse they are. @cache and @dataclass all day baby

kylefluto
Автор

I love that you called out the issue with __slots__

The default dict instance representation has turned my implentation into a massive memory hog, tuple instance representation fixed that!

Maybe __slots__ and other memory optimization and profiling techniques could be the topic of a future video!

dgnikon
Автор

About 2 years ago I came over from writing bare C to having Python as my daily driver. I've grown to really enjoy the language. 95% of the time it suits my needs and videos like this just illustrate how absolutely brilliant it can be. Thanks for the new trick up my sleeve!!!

taylormallory
Автор

I have just started experimenting with Python to use animation libraries from Grant Sanderson / 3Blue1Brown and have seen your videos pop up. Your organization and presentation of these tips is great for both initial learning and reference. Very concise, straightforward examples without cryptic foo / bar based variables, etc. New subscriber!

stratfanstl
Автор

**Note: As of Python 3.10 data classes DO support slots.**

Thanks for adding it to the description, this video is gold!

lordtejas
Автор

LMAO That pause and eye contact after he read "I just subscribed". I FELT THE PRESSURE MAN!

bartugonulalan
Автор

U got me with the “I just subscribed “ look lolol

fritazz