Flexible Collating (feedback please)

Leo Kislov Leo.Kislov at gmail.com
Thu Oct 19 12:28:16 CEST 2006


Ron Adam wrote:

> locale.setlocale(locale.LC_ALL, '')  # use current locale settings

It's not current locale settings, it's user's locale settings.
Application can actually use something else and you will overwrite
that. You can also affect (unexpectedly to the application)
time.strftime() and C extensions. So you should move this call into the
_test() function and put explanation into the documentation that
application should call locale.setlocale


>          self.numrex = re.compile(r'([\d\.]*|\D*)', re.LOCALE)

[snip]

>          if NUMERICAL in self.flags:
>              slist = self.numrex.split(s)
>              for i, x in enumerate(slist):
>                  try:
>                      slist[i] = float(x)
>                  except:
>                      slist[i] = locale.strxfrm(x)

I think you should call locale.atof instead of float, since you call
re.compile with re.LOCALE.

Everything else looks fine. The biggest missing piece is support for
unicode strings.

  -- Leo.




More information about the Python-list mailing list