Are there better ways than the following to determine whether a float is nan or inf? strg=val.__repr__() if strg=='nan' or strg=='inf': ** do something ** where 'val' is the float. Tim