def _float_or_none(x, digits=3):
 if (x is None):
  return str(x)
 fmtstr = u'{0:.{digits}g}'.format(x, digits=digits)
 return fmtstr.format(x)

def _float_or_none ( x , digits = 3 ) : if ( x is None ) : return str ( x ) fmtstr = u'{0:.{digits}g}' . format ( x , digits = digits ) return fmtstr . format ( x )
helper function to format a variable that can be a float or none .