Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

float().__format__() default alignment #51106

skrah mannequin opened this issue Sep 7, 2009 · 6 comments

float().__format__() default alignment #51106

skrah mannequin opened this issue Sep 7, 2009 · 6 comments
type-bug An unexpected behavior, bug, or error


Copy link

skrah mannequin commented Sep 7, 2009

BPO 6857
Nosy @mdickinson, @ericvsmith, @skrah

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = ''
closed_at = <Date 2010-02-22.19:30:44.566>
created_at = <Date 2009-09-07.15:46:46.809>
labels = ['type-bug']
title = 'float().__format__() default alignment'
updated_at = <Date 2010-02-22.19:30:44.565>
user = '' fields:

activity = <Date 2010-02-22.19:30:44.565>
actor = 'eric.smith'
assignee = 'eric.smith'
closed = True
closed_date = <Date 2010-02-22.19:30:44.566>
closer = 'eric.smith'
components = []
creation = <Date 2009-09-07.15:46:46.809>
creator = 'skrah'
dependencies = []
files = []
hgrepos = []
issue_num = 6857
keywords = []
message_count = 6.0
messages = ['92370', '92378', '92379', '92431', '92432', '99817']
nosy_count = 3.0
nosy_names = ['mark.dickinson', 'eric.smith', 'skrah']
pr_nums = []
priority = 'normal'
resolution = 'accepted'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'behavior'
url = ''
versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

Copy link
Mannequin Author

skrah mannequin commented Sep 7, 2009

format(float("0.12345"), "7.0") -> ' 0.1'

The default alignment should be 'left-aligned'.

Copy link

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.

Copy link

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.


@ericvsmith ericvsmith self-assigned this Sep 7, 2009
Copy link

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:

Copy link

Thanks for the decimal work, Mark. I notice that complex is also left
aligned, by default. I'll take a look at that.

Copy link

With the fixes for complex in bpo-7988, I believe this issue is completed.

@ericvsmith ericvsmith added the type-bug An unexpected behavior, bug, or error label Feb 22, 2010
@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
type-bug An unexpected behavior, bug, or error
None yet

No branches or pull requests

2 participants