Issue 6857: float().format() default alignment (original) (raw)
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/51106
classification
Title: | float().__format__() default alignment | ||
---|---|---|---|
Type: | behavior | Stage: | resolved |
Components: | Versions: | Python 3.0, Python 3.1, Python 2.7, Python 2.6 |
process
Status: | closed | Resolution: | accepted |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | eric.smith | Nosy List: | eric.smith, mark.dickinson, skrah |
Priority: | normal | Keywords: |
Created on 2009-09-07 15:46 by skrah, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (6) | ||
---|---|---|
msg92370 - (view) | Author: Stefan Krah (skrah) * ![]() |
Date: 2009-09-07 15:46 |
format(float("0.12345"), "7.0") -> ' 0.1' The default alignment should be 'left-aligned'. | ||
msg92378 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2009-09-07 17:42 |
Hmm. PEP 3101 does indeed say that left-aligned is the default, but it's a bit of a strange default for numeric types. I'd expect integers (at least) to be right-aligned by default. I'd be inclined to say that the current float formatting is correct, and that it's the Decimal formatting that's wrong. | ||
msg92379 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2009-09-07 17:52 |
That is interesting. I'd agree that it's a bug in the PEP. Note that %-formatting right aligns floats by default: >>> '%7.0g' % 0.12345 ' 0.1' I'll raise the issue on python-dev. Eric. | ||
msg92431 - (view) | Author: Mark Dickinson (mark.dickinson) * ![]() |
Date: 2009-09-08 20:25 |
I've changed the default alignment for Decimal instances to right-aligned (so that it agrees with floats and ints) in r74723 (trunk), r74725 (py3k), as agreed in the python-dev thread starting at: http://mail.python.org/pipermail/python-dev/2009-September/091640.html | ||
msg92432 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2009-09-08 20:31 |
Thanks for the decimal work, Mark. I notice that complex is also left aligned, by default. I'll take a look at that. | ||
msg99817 - (view) | Author: Eric V. Smith (eric.smith) * ![]() |
Date: 2010-02-22 19:30 |
With the fixes for complex in issue 7988, I believe this issue is completed. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:52 | admin | set | github: 51106 |
2010-02-22 19:30:44 | eric.smith | set | status: open -> closedpriority: normaltype: behaviormessages: + resolution: acceptedstage: resolved |
2009-09-08 20:31:49 | eric.smith | set | messages: + |
2009-09-08 20:25:55 | mark.dickinson | set | messages: + |
2009-09-07 17:52:40 | eric.smith | set | assignee: eric.smithmessages: + |
2009-09-07 17:42:43 | mark.dickinson | set | nosy: + mark.dickinsonmessages: + |
2009-09-07 15:49:48 | skrah | set | nosy: + eric.smith |
2009-09-07 15:46:46 | skrah | create |