locale doesn' format
malaclypse2 at gmail.com
Mon Jul 20 23:59:08 CEST 2009
On Mon, Jul 20, 2009 at 5:07 PM, Egon Frerich<egon.frerich at nord-com.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
> I want to format values to the german form eg. 1.034,56 but
> locale.format() doesn't work for me.
> Here is a little test program:
> k1 = locale.format_string('%12s',k,True)
I don't think you want to be using '%s' to format numbers in your
format strings. Instead, use '%f' to format floating point values.
As I understand it, a %s in a format string actually calls str() on
the object that you pass into the formatting function, and I don't
think that floats (or Decimal.Decimal objects) take locale into
account when you do that.
More information about the Python-list