↑ ↓ Navigate ↡ Select ESC Close

Python Data Classes Are AMAZING! Here's Why

2024-03-13 Education
121.6k
3.0k
87
Tech With Tim
Tech With Tim
2.0m subscribers

Unlock all features

FREE: Get instant access to 10 AI summaries, chats, or transcripts per day.

Description

To learn programming and Python - check out Datacamp! πŸ’» Learn Python - https://datacamp.pxf.io/WqWaze πŸ’» Learn Programming - https://datacamp.pxf.io/EKrXPD In this video, you'll discover why data classes are a game-changer for Python developers for simplifying code and enhancing readability. If you want to land a developer job: https://techwithtim.net/dev 🎞 Video Resources 🎞 Docs: https://docs.python.org/3/library/dataclasses.html#class-variables ⏳ Timestamps ⏳ 00:00 | Before Data Classes 01:14 | An Intro To Data Classes 01:47 | How A Data Class Works 04:57 | If You Want To Become A Developer 05:49 | Data Class Example 06:58 | Optional Arguments 07:53 | Default Parameters 10:28 | A Quick Tip - Help() 10:55 | Class Variables 11:39 | Inheritance 14:03 | InitVar Hashtags #python #dataclasses #programming

Top Comments (10)

@TechWithTim 2024-03-13

To learn programming and Python - check out Datacamp! πŸ’» Learn Python - https://datacamp.pxf.io/WqWaze πŸ’» Learn Programming - https://datacamp.pxf.io/EKrXPD

3 2 replies
@marktaylor9886 2024-03-16

I've been watching old videos, so good to finally see you on VS Code! haha

10
@DrDeuteron 2024-03-18

I was given a csv file with 524 columns of date times, instrument telemetry, etc...dataclass saved the day...just cut and paste the column header names and let the decorator do the rest. Also put the in-spec limits in the field's metadata along with LaTex strings for y-axis labels. 524...times. data class ftw.

17 3 replies
@tuannguyenanh7466 2024-08-11

Oh, basically a decorator function that wrap a class. Nice

1
@rafacoluccijf 2024-03-14

I am still not conviced. Sure, for small classes with a few fields and logic it might be worth it. But in real world prod code you will have inheritance, polymorphism, logic, dependecies, etc. and you will end up having to implement all those "hacks" you mentioned. Simple classes will be much easier to understand and read and will have probably less overhead. Dont get me wrong, it is a nice tool to have in mind but call it AMAZING is a little too much IMHO. It would be much better if Dataclass just worked without having to implement all those hacks like post_init. I think it is designed to be use as placeholders for data you get from a database for example.

17
@RebukX2 2024-03-16

Man this will be a good and convenient way of reduced my classes code in my current project. Thanks for such good content, and also at the perfect time 😜

1
@sobi-94 2024-03-13

I've only just started watching this video but I just want to say you're really talented and informative. I think you're excellent at conveying what's going on in a simplified way. I think this is the earliest I've ever been for one of your videos haha. Please keep doing what you're doing for the computer science and data science space! Sending you blessings from the UK☺

14
@Corsa15DT 2025-03-23

the allmight python can do everything, but if you want to make a legacy instance variable list you need special class factory and if you want static class variables you need specia class variables library :)

2
@jb_makesgames2264 2024-09-07

As a beginner in python I like your level of detail - a lot of youtubers make assumptions about the details of python.

0
@rockstarj3 2024-03-14

Perfect timing for this video. I was able to use it right away in my project.

1

Unlock the Data Inside
Turn Videos into Knowledge

  • Get FREE 10/day: transcripts, summaries, chats
  • Chat with videos, export text & PDF
  • $1 free API credit for RAG, chatbots & research

Free forever plan β€’ All features unlocked

App screenshot