I'm not sure I get it. What's the purpose of using a delegate rather than having the object itself supply the return value?

Alex Martelli wrote:
Lowell Kirsh <[EMAIL PROTECTED]> wrote:


What might these exceptions be?


It's HIGHLY advisable to have your __getattr__ methods raise
AttributeError for any requested name that starts and ends with double
underscores, possibly with some specific and specifically designed
exceptions.


For example, delegation of such requests to some other object:
    def __getattr__(self, name):
        return getattr(self._delegate, name)

In such cases you may decide you do not need to block __specials__,
because you're OK with having self._delegate supply them or be
responsible to raise AttributeError if necessary.


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

Reply via email to