I i need a decorator that adds a local variable in the function it
decorates, probably related with nested scopes, for example:

def dec(func):
    def wrapper(obj = None):
        if not obj : obj = Obj()
  <bind obj to func>
 return func()

    return wrapper()

@dec()
def fun(b):
    obj.desc = 'marked'
    obj.b = b
    return obj

so the call to fun : fun(obj = myobj,'b argument')
or fun('b argument')

So the function "fun" assumes it has an obj instance and other instance
objects computed by the decorator, this decorator will be like a generic
factory for this kind of functions,which depends on the decorator to work.


    

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

Reply via email to