def safe_string(value):
 if isinstance(value, NUMERIC_TYPES):
  value = ('%.16g' % value)
 elif (value is None):
  value = 'none'
 elif (not isinstance(value, basestring)):
  value = str(value)
 return value

def safe_string ( value ) : if isinstance ( value , NUMERIC_TYPES ) : value = ( '%.16g' % value ) elif ( value is None ) : value = 'none' elif ( not isinstance ( value , basestring ) ) : value = str ( value ) return value
safely and consistently format numeric values .