I have the declared a class in following way
class A:
def __init__(self, list_1, list_2):
self.list1 = list_1
self.list2 = list_2
def __getattr__(self, item):
if item in self.list1: return "It is in list 1"
elif item in self.list2: return "It is in list 2"
else: return "It is in neither list 1 nor list 2"
Here when I am adding __setattr__ self.list1 goes recursive, since __getattr__ get called after every self.list1 and this recursion is unstoppable. Can you please help me out with it. I need to implement like this.
Thanks
__setattr__but it is not in your code. Please explain how you are using__setattr__, if you are.if item in ["list1","list2"]: return self.__dict__[item]at the start of__getattr__().