Terry J. Reedy added the comment:
This came up again on python-list today in thread "Replace weird error
message?" by "the.gerenuk--- via Python-list". After reading the discussion, I
decided that expecting someone to read and connect together two sentences half
a page apart is expecting a bit too much.
'''
'=' Forces the padding to be placed after the sign (if any) but before the
digits. This is used for printing fields in the form ‘+000000120’. This
alignment option is only valid for numeric types.
'''
Add "It becomes the default when '0' precedes the field width."
'''
Preceding the width field by a zero ('0') character enables sign-aware
zero-padding for numeric types. This is equivalent to a fill character of '0'
with an alignment type of '='.
'''
This is not true when an explicit alignment other than '=' is given.
>>> "{:09}".format(-1)
'-00000001'
>>> "{:>09}".format(-1) # 2.7.11 and 3.5.1
'0000000-1'
Proposal: Replace with
'''
When no explicit alignment is given, preceding the width field by a zero ('0')
character enables sign-aware zero-padding for numeric types. This is equivalent
to a fill character of '0' with an alignment type of '='.
'''
I presume the problem with changing the error message is that it is not
immediately known that alignment was set implicitly, by 0 before decimal width,
rather than explicitly. If the spec string is still available, it could be
searched and the message adjusted if '=' is not present. That proposal should
be a new issue if someone wants to push it.
----------
resolution: fixed ->
stage: resolved -> patch review
status: closed -> open
versions: +Python 3.5, Python 3.6 -Python 3.2, Python 3.3
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue15660>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com