basically i am trying to golf this code
class A:
def __init__(self, data: List):
self.data = data
def __iter__(self):
return iter(self.data)
into something like this
class A:
def __init__(self, data: List):
self.data = data
self.__iter__ = data.__iter__
but python doesn't recognise the magic method and says the object is not iterable. is there any way to do this?