How is __metaclass__ used in real life.
Vimarsh Chaturvedi (~vimarsh) |
Class objects in python are themselves instances of the
type class. Usage of the
metaclass allows you to modify the process of creating a class object. Practical use-cases use
metaclass attribute to add, delete, rename, or substitute methods and attributes in the class that is initiated.
- Class objects are instances of
- How to override the
- Introduction to the
- How to create singleton classes in Python
metaclassto introduce methods in a class without inheritance
metaclassis used in Django REST Framework Serializers.
- How Django uses
metaclassto maintain backward compatibility
- Intermediate familiarity object oriented programming concepts and how inheritance works in Python
- Basic understanding of serializers (Not compulsory).
Vimarsh Chaturvedi is currently working at Hedgehog labs as Developer. Graduated from Delhi Technological University in 2016. Lover of Python and small time contributor to Django REST Framework. In his spare time he likes to get into the nuts and bolts of Django and Django REST Framework. Likes to override DRF functionalities and write
mixins on steroids for fun. Firm believer of if you have to write the same code twice there is a more elegant way to do it.