News for hackers. Stuff that matters.
Re:Problems once solved by a metaclass can be solved by __in... by tybug on Wednesday January 05, 2022 @12:56PM (#29812446)
The most salient example I can think of is tracking all subclasses of a class. This is how django tracks `Model` subclasses to create a table for each model, for instance. I wrote a blog post on this topic: https://tybug.github.io/2021/11/06/tracking-all-subclasses-o...

I've also used metaclasses in the past to apply a decorator to certain methods of all subclasses, without needing to specify that decorator in the subclass declaration itself.

Re:Problems once solved by a metaclass can be solved by __in... by dbrueck on Wednesday January 05, 2022 @06:41PM (#29816906)
Came here to say this. This is my most common use of metaclasses, and __init_subclass__ looks to be a much cleaner solution.