I have no time for a long discussion, but the code should
speak for itself:

class Container(object):
    def __init__(self, content):
        self.content = content
    def __str__(self):
        return "<Container containing %r>" % self.content

class Wrapped(object):
    def __init__(self, obj):
        self._obj = obj
    def __getattribute__(self, name):
        obj = super(Wrapped, self).__getattribute__("_obj")
        return getattr(obj, name)

w = Wrapped(Container("hello"))

print w.content
print w.__str__() # works
print w # does not work as you would expect, see bug report SF 729913

The discussion around the bug report is worth reading,

             Michele Simionato

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to