[New-bugs-announce] [issue19238] Misleading explanation of fill and align in format_spec

David Chambers report at bugs.python.org
Sun Oct 13 00:27:49 CEST 2013


New submission from David Chambers:

>From http://docs.python.org/3/library/string.html#formatspec:

> The presence of a fill character is signaled by the character
> following it, which must be one of the alignment options. If the
> second character of format_spec is not a valid alignment option,
> then it is assumed that both the fill character and the alignment
> option are absent.

The fact that the second character in the format_spec is not an
alignment option is not sufficient to declare that the alignment
option is absent: the alignment option may be the first character
in the format_spec. For example:

    >>> '{:^10}'.format(42)
    '    42    '

I suggest the following wording:

The presence of a fill character is signaled by the character
following it, which must be one of the alignment options. Unless
the second character of format_spec is a valid alignment option,
the fill character is assumed to be absent.

----------
assignee: docs at python
components: Documentation
messages: 199633
nosy: davidchambers, docs at python
priority: normal
severity: normal
status: open
title: Misleading explanation of fill and align in format_spec

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue19238>
_______________________________________


More information about the New-bugs-announce mailing list