def wrapper (*args):
            '''
            Function wrapper that checks argument types.
            '''
            assert len(args) == len(types), 'Wrong number of arguments.'
            for a, t in zip(args, types):
                if type(t) == type(()):
                    # any of these types are ok
                    assert sum(isinstance(a, tp) for tp in t) > 0, '''\
%s is not a valid type.  Valid types:
%s
''' % (a, '\n'.join(str(x) for x in t))
                assert isinstance(a, t), '%s is not a %s type' % (a, t)
            return func(*args)

            Function wrapper that checks argument types.
            
recipes/Python/355638_Type_checked_argument_lists/recipe-355638.py