rendered paste bodyfrom types import *class tc: def __init__(self, types=[]): self.types = types def _wrapper(self, func): def new_func(*args): if len(self.types)<>len(args): raise IndexError, 'Argument count mismatch' for i in range(len(args)): if type(args[i])<>self.types[i]: raise TypeError, 'Parameter type mismatch - paramater %s' % i return func(*args) return new_funcdef type_check(*types): checker = tc(types) return checker._wrapper@type_check(int, int)def test_int(a, b): print a + b @type_check(float, int)def test_float(a, b): print a + b#workstest_int(1,2)#raises exceptiontest(1.1, 2)#workstest_float(1.1, 2)