Message71677
IMO, I'd be better to always ignore missing attributes. Consider another
use case (following code I've posted also on comp.lang.python):
from functools import wraps, partial
def never_throw(f):
@wraps(f)
def wrapper(*args, **kwargs):
try: return f(*args, **kwargs)
except: pass
return wrapper
Looks reasonable. But if I write
never_throw(partial(int))('45a')
I got the exception saying partial objects also don't have __module__
attribute.
I was to use some additional parameters to @wraps, I would have to
rewrite all my decorator definitions. And stil -- the main intent of
wraps and update_wrapper is to write decorators, so IMO they should not
throw on missing attributes. |
|
Date |
User |
Action |
Args |
2008-08-21 20:33:41 | findepi | set | recipients:
+ findepi, ncoghlan, pitrou, benjamin.peterson, Antoine d'Otreppe |
2008-08-21 20:33:41 | findepi | set | messageid: <1219350821.16.0.848573229931.issue3445@psf.upfronthosting.co.za> |
2008-08-21 20:33:40 | findepi | link | issue3445 messages |
2008-08-21 20:33:39 | findepi | create | |
|