Skip to content

Preceding the width field by '0' affects the default alignment for strings using str.format() on Python 3.12.7 #136386

Closed as not planned
@hyperkai

Description

@hyperkai

Bug report

Bug description:

[The doc](https://docs.python.org/3/library/string.html#format-specification-mini-language) says below:

Changed in version 3.10: Preceding the width field by '0' no longer affects the default alignment for strings.

But, preceding the width field by '0' affects the default alignment for strings using str.format() says below:
on Python 3.12.7 as shown below:

v = "Hello" # ↓ print('{0:<08}'.format(v)) # Hello000 # ↓ print('{0:>08}'.format(v)) # 000Hello

CPython versions tested on:

3.12

Operating systems tested on:

Windows

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions