Python Professional — Hard
Key points
- __class_getitem__ is called when a class is subscripted
- It returns a GenericAlias or custom object
- Enables classes to support type parameters in annotations
- Facilitates generic type hinting in Python
Ready to go further?
Related questions
