[issue32790] Keep trailing zeros in precision for string format option g

2018-02-08 Thread Severin Wünsch

Severin Wünsch <swuen...@gmail.com> added the comment:

This meet my needs.

Maybe the documentation could also add this information in the chart for 'g' 
here: 
https://docs.python.org/3.7/library/string.html#format-specification-mini-language
 as only into the running text. As I did not notice it.

As the text in the table for 'g' is already long, if you do not want to add all 
the same information again, add at least that trailing zeros will get removed.

--

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32790>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32790] Keep trailing zeros in precision for string format option g

2018-02-07 Thread Severin Wünsch

New submission from Severin Wünsch <swuen...@gmail.com>:

The documentation starts the the string format parameter 'g':

General format. For a given precision p >= 1, this rounds the number to **p 
significant digits** and then formats the result in either fixed-point format 
or in scientific notation, depending on its magnitude.

I think the behavior of format is inconsistent here:
>>> format(0.1949, '.2g')
returns '0.19' as expected but
>>> format(0.1950, '.2g')
returns '0.2' instead of '0.20'

This behavior for float is in my opinion the correct one here
>>> format(0.1950, '.2f')
returns '0.20'

--
messages: 311813
nosy: sk1d
priority: normal
severity: normal
status: open
title: Keep trailing zeros in precision for string format option g
type: behavior
versions: Python 3.7

___
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue32790>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com