Replace weird error message?

Joel Goldstick joel.goldstick at gmail.com
Wed Mar 16 15:02:51 EDT 2016


On Wed, Mar 16, 2016 at 2:53 PM, Ben Finney <ben+python at benfinney.id.au>
wrote:

> "the.gerenuk--- via Python-list" <python-list at python.org> writes:
>
> > The following error message, makes it a bit hard to understand what went
> wrong
> >
> > >>> "{:02}".format("1")
> > Traceback (most recent call last):
> >   File "<stdin>", line 1, in <module>
> > ValueError: '=' alignment not allowed in string format specifier
>
> Meaning that the ‘str.format’ mini-language parser has decided on the
> alignment specifier “=”. It's chosen that because:
>
>     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 '='.
>
>     <URL:https://docs.python.org/3/library/string.html#formatspec>
>
> Nothing in the error message indicates why “'=' alignment” is relevant,
> and it does not appear in the code.
>
> > Do you think some better error message should be used?
>
> Yes, I think that error message needs to be improved. Please file a bug
> report in Python's issue tracker <URL:https://bugs.python.org/>.
>
> > For example a hint that "0" does work for the given argument.
>
> I suggest: “zero-padding only allowed for numeric types, not 'str'”.
>
> --
>  \         “In economics, hope and faith coexist with great scientific |
>   `\      pretension and also a deep desire for respectability.” —John |
> _o__)                                    Kenneth Galbraith, 1970-06-07 |
> Ben Finney
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I stand corrected.  It was awfully misleading.  So much so that I thought
some other code must have been missing.

-- 
Joel Goldstick
http://joelgoldstick.com/ <http://joelgoldstick.com/stats/birthdays>
http://cc-baseballstats.info/



More information about the Python-list mailing list