"the.gerenuk--- via Python-list" <python-list@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