On Mon, Dec 3, 2012 at 6:30 PM, Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info> wrote: > Yeah, in hindsight it was a pretty crappy example. But this sort of > dynamism really is useful: > > def testRaises(exc, func, *args): > try: > result = func(*args) > except exc: > return > raise AssertionError("expected exception but didn't get one") > > > def wrap(func, exc, default=None): > @functools.wraps(func) > def inner(*args): > try: > return func(*args) > except exc: > return default > return inner
Ah, that makes good sense. The 'except' clause takes a parameter, so it follows logically that you could pass a parameter to something that wraps an except clause. ChrisA -- http://mail.python.org/mailman/listinfo/python-list