This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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) * (Python committer) 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:52adminsetgithub: 51106
2010-02-22 19:30:44eric.smithsetstatus: open -> closed
priority: normal
type: behavior
messages: + msg99817

resolution: accepted
stage: resolved
2009-09-08 20:31:49eric.smithsetmessages: + msg92432
2009-09-08 20:25:55mark.dickinsonsetmessages: + msg92431
2009-09-07 17:52:40eric.smithsetassignee: eric.smith
messages: + msg92379
2009-09-07 17:42:43mark.dickinsonsetnosy: + mark.dickinson
messages: + msg92378
2009-09-07 15:49:48skrahsetnosy: + eric.smith
2009-09-07 15:46:46skrahcreate