2013/7/7 Steven D'Aprano <steve+comp.lang.pyt...@pearwood.info>: > I sometimes find myself needing to promote[1] arbitrary numbers > (Decimals, Fractions, ints) to floats. E.g. I might say: > > numbers = [float(num) for num in numbers] > > or if you prefer: > > numbers = map(float, numbers) > > The problem with this is that if a string somehow gets into the original > numbers, it will silently be converted to a float when I actually want a > TypeError. So I want something like this: > >... > -- > Steven > -- Hi, I guess, a naive approach like
numbers = [float(num+0) for num in numbers] wouldn't satisfy the performance requirements, right? vbr -- http://mail.python.org/mailman/listinfo/python-list