[issue33731] string formatting that produces floats with preset precision while respecting locale

2019-08-14 Thread Cédric Krier

Cédric Krier  added the comment:

I think PR-15275 will solves this issue also as you could use:

>>> locale.setlocale(locale.LC_ALL, 'fr_FR')
>>> locale.localize('{:.2f}'.format(1.891))
'1,89'

--
nosy: +ced

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-04 Thread Stefan Krah


Change by Stefan Krah :


--
nosy: +skrah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


James Emerton  added the comment:

@rhettinger See #34311 about formatting Decimals using locale.format(). I'd 
like to see the problem fixed in one place or the other.

Also, this is seems relatively straightforward to implement as it's really just 
a combination of the fixed precision 'f' and the locale specific 'n' format 
types.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

I would like to see locale() remain somewhat decoupled from the rest of string 
formatting.  IIRC locale() is finicky especially when concurrency is involved.  
I think a best practice is for an app to address locale issues explicitly 
rather than inside string formatting.  I'll defer to those with more experience 
using locale -- I just have a vague recollection of this being an area fraught 
with landmines.

--
nosy: +rhettinger

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


James Emerton  added the comment:

So far, I've implemented this for Decimal

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +8118
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-08-01 Thread James Emerton


Change by James Emerton :


--
nosy: +jemerton

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-06-01 Thread Eric V. Smith


Eric V. Smith  added the comment:

You can always use the locale module, although of course that's not as 
convenient:

>>> locale.format('%.2f', 1.891)
'1.89'

I'm open to suggests on backward compatible ways to implement this for python 
3.8. It would probably involve a new letter, and need to be implemented for at 
least int, float, decimal, and complex.

--
assignee:  -> eric.smith
components: +Interpreter Core -Extension Modules
versions: +Python 3.8 -Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33731] string formatting that produces floats with preset precision while respecting locale

2018-06-01 Thread Jakub Szewczyk


New submission from Jakub Szewczyk :

.2f produces a string representation of a float rounded up to 2 significant 
digits.

>>> print ("{:.2f}".format(1.891))
1.89

However, it does not respect locale. There is no counterpart of 'f' that would 
respect locale. There is 'n', but because it follows the rules of 'g', in many 
cases it returns a different number of significant digits. 

>>> print ("{:.2n}".format(1.891))
1.9


In all my uses of formatted float printing, I need to produce floats that are 
rounded to have the same number of significant digits. I _presume_ this 
generalizes to the majority people, and the use of 'f' option is much more 
widespread than the use of 'g'. If this is the case, then a locale-friendly 
counterpart of 'f' would be very useful.

--
components: Extension Modules
messages: 318407
nosy: Jakub Szewczyk, eric.smith
priority: normal
severity: normal
status: open
title: string formatting that produces floats with preset precision while 
respecting locale
type: enhancement
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com