def args(*types, **ktypes):
    'Allow testing of input types:\n    argkey=(types) or argkey=type'

    def decorator(func):

        def modified(*args, **kargs):
            position = 1
            for (arg, T) in zip(args, types):
                if (not isinstance(arg, T)):
                    raise TypeError(('Positional arg (%d) should be of type(s) %s, got %s' % (position, T, type(arg))))
                position += 1
            for (key, arg) in kargs.items():
                if (key in ktypes):
                    T = ktypes[key]
                    if (not isinstance(arg, T)):
                        raise TypeError(("Keyworded arg '%s' should be of type(s) %s, got %s" % (key, T, type(arg))))
            return func(*args, **kargs)
        return modified
    return decorator
Allow testing of input types:
argkey=(types) or argkey=type
def args(*types, **ktypes):
    'Allow testing of input types:\n    argkey=(types) or argkey=type'

    def decorator(func):

        def modified(*args, **kargs):
            position = 1
            for (arg, T) in zip(args, types):
                if (not isinstance(arg, T)):
                    raise TypeError(('Positional arg (%d) should be of type(s) %s, got %s' % (position, T, type(arg))))
                position += 1
            for (key, arg) in kargs.items():
                if (key in ktypes):
                    T = ktypes[key]
                    if (not isinstance(arg, T)):
                        raise TypeError(("Keyworded arg '%s' should be of type(s) %s, got %s" % (key, T, type(arg))))
            return func(*args, **kargs)
        return modified
    return decorator