The 'n' format specifier

Boštjan Mejak bostjan.mejak at gmail.com
Thu Oct 21 04:32:38 EDT 2010


The locale.setlocale(category=locale.LC_NUMERIC, locale="Slovenian")  works
like a charm in my application. Now the 'n format specifier works as I want.
But tell me whether the 'n' forma specifier can be forced to round the float
to just one decimal place. I know that the 'f' format specifier does that by
specifying ".1f", but 'f' is not locale-aware. I have set the 'n' format
specifier in my application like ".3n", which is okay if the returned number
is two integers and one decimal, but is not okay if the returned number is
one integer and two decimals, because I want just one decimal, always. How
can I make that by using the 'n' format specifier?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20101021/b552794f/attachment.html>


More information about the Python-list mailing list