Skip to content

float().__format__() default alignment #51106

Closed

Description

@skrah
mannequin
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 = 'https://github.com/ericvsmith'
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 = 'https://github.com/skrah'

bugs.python.org 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 = 'https://bugs.python.org/issue6857'
versions = ['Python 2.6', 'Python 3.0', 'Python 3.1', 'Python 2.7']

Activity

  1. skrah commented on Sep 7, 2009

    skrahmannequin
    MannequinAuthor

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

    The default alignment should be 'left-aligned'.

  2. mdickinson commented on Sep 7, 2009

    @mdickinson
    Member

    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.

  3. ericvsmith commented on Sep 7, 2009

    @ericvsmith
    Member

    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.

  4. self-assigned this
    on Sep 7, 2009
  5. mdickinson commented on Sep 8, 2009

    @mdickinson
    Member

    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

  6. ericvsmith commented on Sep 8, 2009

    @ericvsmith
    Member

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

  7. ericvsmith commented on Feb 22, 2010

    @ericvsmith
    Member

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

  8. added
    type-bug
    on Feb 22, 2010
  9. transferred this issue fromon Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

type-bug

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions