What do I need to change to make this work?
class A: @staticmethod def __getitem__(val): return \"It works\" print A[0]
No
Python 3.7 introduced __class_getitem__.
class A: def __class_getitem__(cls, key): return "It works" print(A[0])