Is it possible, and if so, advisable, and if so, what would be the recommended method for decorating a function that yields a value?
For example, consider this imaginary example I made up
def foobar_creator(func):
def wrapped(**kwargs):
res = func(**kwargs)
flag = True
for k,v in kwargs:
if res % v == 0:
flag = False
yield k
if flag:
yield res
return wrapped
@foobar_creator
def generic_yielder(**kwargs):
for i in xrange(sys.maxint):
yield i
for i in generic_yielder(foo=3, bar=5, foobar=15):
print i