def filter_format_number(val, places=None, grouping=True):
 if (not isinstance(val, (int, float, int))):
  return val
 if (places is not None):
  format = ((u'%.' + str(places)) + u'f')
 elif isinstance(val, (int, int)):
  format = u'%d'
 else:
  format = u'%.02f'
 locale.setlocale(locale.LC_ALL, u'')
 return locale.format(format, val, grouping)

def filter_format_number ( val , places = None , grouping = True ) : if ( not isinstance ( val , ( int , float , int ) ) ) : return val if ( places is not None ) : format = ( ( u'%.' + str ( places ) ) + u'f' ) elif isinstance ( val , ( int , int ) ) : format = u'%d' else : format = u'%.02f' locale . setlocale ( locale . LC_ALL , u'' ) return locale . format ( format , val , grouping )
formats a number according to the users locale .