Jeff Shannon wrote:
You could probably also do this as a factory function, rather than as a class (also untested!):

def Wrapper(func):
    def wrapped(self, *args, **kwargs):
        s, r = func(self, *args, **kwargs)
        if s != 'OK':
            raise NotOK((s,r))
        return r
    return wrapped

I believe that this will be semantically almost equivalent, but conceptually slightly simpler.

Jeff Shannon

This is a nice example. I have used sub-functions (functions within functions) recently with some code, but I've wondered how proper it is to do this. Is this type of thing frowned upon?
--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to