from functools import reduce
class C(object):
    _oncreate = []

def __new__(cls):
    return reduce(lambda x, y: y(x), cls._oncreate, super(C, cls).__new__(cls))

@classmethod
def oncreate(cls, func):
    cls._oncreate.append(func)
c = C()
print(hasattr(c, 'spew'))

@C.oncreate
def spew(obj):
    obj.spew = 42
return obj
c = C()
print(c.spew)
What's the preferred way to implement a hook or callback in Python?