08:17If You’re Not Using Python DATA CLASSES Yet, You Should 🚀
From the creator
💡 Learn how to design great software in 7 steps: https://arjan.codes/designguide. This video is a tutorial about Python's dataclasses. I take you through an example that shows what you can do with them. Python data classes are - as you'd expect - in particular suitable to model classes that represent data, and as such they offer easy mechanisms to initialize, print, order, sort, and compare data. Note that although I'm using a sort_index attribute, strictly speaking that's not needed in this case, because a data class uses a tuple of its attributes in the class definition as the default for sorting. I'm not a fan of this kind of hidden behavior, so I prefer to do it explicitly (using something that is called sort_index in this case). Another advantage of using a separate field, is that you can do more complicated ordering, using for example a weighted combination of age and strength. 🎓 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 Intro 0:33 Behavior-driven vs data-driven classes 2:11 Explaining the example 3:31 Creating a dataclass 4:37 Sorting and comparing 6:58 Default values 7:40 Creating read-only (frozen) objects 8:55 String representation of data 9:34 Final thoughts #arjancodes #softwaredesign #python
Published 2021-05-07 · Watch on YouTube ↗
Availability and playback restrictions are controlled by the original channel.
Keep exploring Learn to Code
08:17
16:29
09:14Securing AI Deployments with HashiCorp Vault & Azure | Sip and Sync with Azure
Microsoft Developer
22:43Next-Level SQL in VS Code: GitHub Copilot, Containers & more | Data Exposed
Microsoft Developer
19:28SQL in Fabric–Copilot, Data Virtualization, Notebook Integration & Backup/Restore | Data Exposed
Microsoft Developer
11:13Building a Snapshot Backup Catalog with SQL Server 2025 and Pure Storage FlashArray | Data Exposed
Microsoft Developer
10:24