Re:Customizing class creation in Python
by prashnts on Thursday March 30, 2017 @03:45PM
(#13998320)
While I agree that _this_ is an extreme demonstration, metaclasses are powerful tool for developing dev-friendly Base classes/APIs in your libraries. Django models, for example, use metaclasses so the fields you define are more expressive while creating instances.
[ Parent
| on HN ]
Re:Customizing class creation in Python
by paulddraper on Thursday March 30, 2017 @04:09PM
(#13998489)
That's okay as long as the magic holds. If it starts to fail, you have to peek behind the curtain, and you lose yourself among the meta.
Django famously had a "magic removal" refactor before 1.0 as they collectively decided they had gone too far. They've since plotted a more conservative path but the ORM and similar magic was deemed reasonable.
I've found Django's metaclass usage pretty robust over the years. The curtain mostly remains unpeeked behind.