4 ms·
> Python allows you to get pretty creative with the code you’re writing. For instance, you can: > Use MetaClasses to self-register classes upon code initializa
by yeukhon 9y ago
> Python allows you to get pretty creative with the code you’re writing. For instance, you can:
> Use MetaClasses to self-register classes upon code initialization
Avoid metaclasses....
> Swap out True and False
Not possible anymore
> Add functions to the list of built-in functions
What are the practical reasons?
> Overload operators via magic methods
Useful but also recommend don’t. I can see someone writting numpy would do that, but most applications don’t have a reason
Profile profile profile! Find the bottlenecks.
- tschellenbach 9y agoDjango uses metaclasses quite nicely actually for the the Forms and Model definitions.
- yen223 9y ago"Avoid metaclasses...." Good luck finding a Python library that doesn't use metaclasses anywhere!
- mrgriffin 9y agoHow about Requests? https://github.com/requests/requests/search?utf8=%E2%9C%93&q=metaclass&type= https://github.com/requests/requests/search?utf8=%E2%9C%93&q...