@curry
def lossless_float_to_int(funcname, func, argname, arg):
 if (not isinstance(arg, float)):
  return arg
 arg_as_int = int(arg)
 if (arg == arg_as_int):
  warnings.warn('{f} expected an int for argument {name!r}, but got float {arg}. Coercing to int.'.format(f=funcname, name=argname, arg=arg))
  return arg_as_int
 raise TypeError(arg)

@ curry def lossless_float_to_int ( funcname , func , argname , arg ) : if ( not isinstance ( arg , float ) ) : return arg arg_as_int = int ( arg ) if ( arg == arg_as_int ) : warnings . warn ( '{f} expected an int for argument {name!r}, but got float {arg}. Coercing to int.' . format ( f = funcname , name = argname , arg = arg ) ) return arg_as_int raise TypeError ( arg )
a preprocessor that coerces integral floats to ints .