I've written the following wrapper class. I want to define __setattr__
such that it redirects all attributes to the wrapped class. However, this prevents me from initializing the wrapper class. Any elegant way to fix this?
class Wrapper:
def __init__(self, value):
# How to use the default '__setattr__' inside '__init__'?
self.value = value
def __setattr__(self, name, value):
setattr(self.value, name, value)
Wrapper
wrap? Why doesn't it inheritobject
? – Sisileobject
because I only want to use Python 3. – Bromidic__setattr__()
. – Affirmatory