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

2019-09-13 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:

Thank you for your PR and this issue, the PR is merged into master, 3.8 and 3.7.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.9

___
Python tracker 

___
___
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

2019-09-13 Thread miss-islington


miss-islington  added the comment:


New changeset e6b14c026fd9045a0d460b62dbcb512fca4c64ec by Miss Islington (bot) 
in branch '3.8':
bpo-32790: Add info about alt format using GH- for 'g' in chart (GH-6624)
https://github.com/python/cpython/commit/e6b14c026fd9045a0d460b62dbcb512fca4c64ec


--

___
Python tracker 

___
___
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

2019-09-13 Thread miss-islington


miss-islington  added the comment:


New changeset 77878cadc58aaca234482dffbb5fe89c74c026fa by Miss Islington (bot) 
in branch '3.7':
bpo-32790: Add info about alt format using GH- for 'g' in chart (GH-6624)
https://github.com/python/cpython/commit/77878cadc58aaca234482dffbb5fe89c74c026fa


--
nosy: +miss-islington

___
Python tracker 

___
___
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

2019-09-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15734
pull_request: https://github.com/python/cpython/pull/16121

___
Python tracker 

___
___
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

2019-09-13 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15735
pull_request: https://github.com/python/cpython/pull/16122

___
Python tracker 

___
___
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

2019-09-13 Thread Stéphane Wirtel

Stéphane Wirtel  added the comment:


New changeset d44542f9a231bf725ecd82eb640a672c759a8227 by Stéphane Wirtel 
(bchhabra2490) in branch 'master':
bpo-32790: Add info about alt format using # for 'g' in chart (GH-6624)
https://github.com/python/cpython/commit/d44542f9a231bf725ecd82eb640a672c759a8227


--
nosy: +matrixise

___
Python tracker 

___
___
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-04-28 Thread Bharat Chhabra

Change by Bharat Chhabra :


--
keywords: +patch
pull_requests: +6320
stage: needs patch -> patch review

___
Python tracker 

___
___
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-04-26 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +easy
stage:  -> needs patch
versions: +Python 3.8

___
Python tracker 

___
___
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-08 Thread Mark Dickinson

Mark Dickinson  added the comment:

> Maybe the documentation could also add this information in the chart for 'g' 
> here:

Agreed that that would make sense. All the information is *there* in the docs 
(the alternate format is described a bit above that table), but it's not very 
easy to extract the information.

And that table entry is misleading as it currently is, since it suggests that 
trailing zeros are removed unconditionally: "In both cases insignificant 
trailing zeros are removed from the significand, and the decimal point is also 
removed if there are no remaining digits following it."

Perhaps we could adopt something like the wording in the C standard, where it 
says:

> Finally, unless the # flag is used, any trailing zeros are removed
> from the fractional portion of the result and the decimal-point
> character is removed if there is no fractional portion remaining.

Re-classifying as a documentation issue.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

___
___
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-08 Thread Severin Wünsch

Severin Wünsch  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 

___
___
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-08 Thread Mark Dickinson

Mark Dickinson  added the comment:

The behaviour here is intentional, though the reasons for doing it this way are 
at least partly historical: it's the way that %g formatting works in C's 
*printf functions (see C99 7.19.6.1p8 for details), and as a direct result of 
that it's also the way that old-style %-based formatting works in Python. That 
behaviour then got transferred to the new-style .format-based formatting for 
consistency.

I don't think we can or should change the current behaviour here: there's a 
significant risk of breaking existing code.

However, note that C does offer an *alternate* mode for .g-style formatting, 
using the '#' character, and this is also available in Python's formatting, 
both %-based and format-based:

>>> "%.2g" % 0.1950
'0.2'
>>> "%#.2g" % 0.1950
'0.20'

and

>>> format(0.1950, '.2g')
'0.2'
>>> format(0.1950, '#.2g')
'0.20'

Does this meet your needs?

--
nosy: +eric.smith, mark.dickinson

___
Python tracker 

___
___
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 :

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 

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