I don't quite understand why the code below raises a RecursionError?
class A:
def __init__(self):
self.x = 1
class Proxy:
def __init__(self, obj):
self._obj = obj
def __getattr__(self, name):
getattr(self._obj, name)
def __setattr__(self, name, value):
setattr(self._obj, name, value)
a = A()
p = Proxy(a)
I'm just trying to emulate A with Proxy.
I don't think this question is a duplication. The provided answers deal with class hierarchies which are not used here.