[Python-Dev] LC_NUMERIC and C libraries

Martin v. Löwis martin@v.loewis.de
18 Jul 2003 00:49:08 +0200


Christian Reis <kiko@async.com.br> writes:

> The underlying truth is that locale-represented values will not be
> directly convertible to Python's C-locale values.

That is not true. locale.atof should allow you to parse the string.

> I'm not sure this is correct. If it isn't I suggest two alternatives:
> offer an additional float() that *does* support LC_NUMERIC
> (float_localized?), or change float() semantics. 

I think this is unacceptable. In some languages, "." is used as the
thousands-separator. Then, should "1.000" be 1e3, or 1e0?

> There may be [broken] code that relies on float raising a TypeError if
> something like "50,00" is passed to it, however. Other than that it
> seems safe as a special-case.

That code is not broken: It is a feature that float() accepts exactly
the same syntax that you use in source code; see the documentation for
string.atof.

Regards,
Martin