K
Karl Chen
Hi.
Is it possible to make a classmethod out of __getitem__?
I.e. I want to do:
class C:
def __getitem__(p):
return 1+p
__getitem__ = classmethod(__getitem__)
So that C[3] works (in addition to C()[3]). But I always get
TypeError: unsubscriptable object
Is it possible to make a classmethod out of __getitem__?
I.e. I want to do:
class C:
def __getitem__(p):
return 1+p
__getitem__ = classmethod(__getitem__)
So that C[3] works (in addition to C()[3]). But I always get
TypeError: unsubscriptable object