18 Dec
2010
18 Dec
'10
6:43 a.m.
Rather than such a large, monolithic construct, perhaps consider pursuing smaller tweaks that could improve the following. def _check_call(f, x): try: return f(*x) except TypeError: return False if x ==1: pass elif isinstance(x, int): pass elif isinstance(x, tuple) and len(x) == 2: pass elif hasattr(x, 'a') and hasattr(x, 'b'): pass elif _check_call((lambda a, b: a > b), x): pass elif isinstance(x, Foo) and isinstance(getattr(x, 'c', None), int) and getattr(x, 'd', None) == 1: pass else: pass Cheers. Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia