Skip to main content
AmigoFish

You’ve Been Underusing Dataclasses (These Tricks Are Wild)

From ArjanCodes · · 27 min

The player loads from YouTube only when you click. It uses YouTube's privacy-enhanced mode.

If the video does not play, the owner may have turned off embedding. Watch it on YouTube instead.

Watch on YouTube

Not rated yet

Description

🧱 Build software that lasts. Join the Software Design Mastery waiting list → https://arjan.codes/mastery.

In this video, I show you 7 powerful and lesser-known things you can do with dataclasses in Python. From automatic class registration and lightweight validation systems to cached derived values, context managers, CLI generation, and the often misunderstood `InitVar`.

🔥 GitHub Repository: https://git.arjan.codes/2026/dctricks.

🎓 ArjanCodes Courses: https://www.arjancodes.com/courses.

💬 Join my Discord server: https://discord.arjan.codes.

⌨️ Keyboard I’m using: https://amzn.to/49YM97v.

🔖 Chapters: 0:00 Introduction 1:23 1. Dataclass as a Singleton-like Factory 7:12 2. Dataclasses with Automatic Registration 12:17 3. Dataclass Validation System (Mini-Pydantic) 15:59 4. Generating SQL Schemas from Dataclasses (Simplified) 18:39 5. Dataclasses With Cached Properties 21:31 6. Dataclass as a Self-Building CLI Argument Parser 23:59 7. Dataclass as a Context Manager 25:43 Bonus: InitVar Constructor-Only Fields 27:23 Final Thoughts

#arjancodes #softwaredesign #python

Back to ArjanCodes · Report a problem