How to write a static python getitem method?
class A:
@staticmethod
def __getitem__(val):
return "It works"
print A[0]
class MetaA(type):
def __getitem__(cls,val):
return "It works"
class A(object):
__metaclass__=MetaA
pass
print(A[0])
# It works
GoBuyKar Provide Programming Solutions.
If the answers is incorrect or not given, you can answer the above question in the comment box. If the answers is incorrect or not given, you can answer the above question in the comment box.