On Sun, 07 Jul 2013 05:17:01 +0100, Joshua Landau wrote: > On 7 July 2013 04:56, Steven D'Aprano > <steve+comp.lang.pyt...@pearwood.info> wrote: ... >> def promote(x): >> if isinstance(x, str): raise TypeError return float(x)
>>>> from operator import methodcaller >>>> safe_float = methodcaller("__float__") Nice! That's almost as fast as calling float. That will probably do :-) -- Steven -- http://mail.python.org/mailman/listinfo/python-list