Author terry.reedy
Recipients docs@python, eric.smith, ezio.melotti, py.user, python-dev, terry.reedy
Date 2016-03-16.20:56:02
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1458161762.91.0.990190423499.issue15660@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2016-03-16 20:56:02terry.reedysetrecipients: + terry.reedy, eric.smith, ezio.melotti, docs@python, py.user, python-dev
2016-03-16 20:56:02terry.reedysetmessageid: <1458161762.91.0.990190423499.issue15660@psf.upfronthosting.co.za>
2016-03-16 20:56:02terry.reedylinkissue15660 messages
2016-03-16 20:56:02terry.reedycreate