On Wednesday, March 16, 2016 at 1:53:45 PM UTC-5, Dan Strohl wrote: > Actually, I think that was the complete code... give it a try... > > "{:02}".format("1") > > produces the error listed. > > I agree the error is not very clear, since the "=" was not > passed, it seems like an incorrect error. What about > something like: > > "ValueError: '=' and '0' padding are not allowed in string > format specifiers"
I strongly disagree with your proposal. Yes, your proposal is better than the original, but it is still too confusing. Error messages should never be confusing, or lie, or offer more than one reason why the exception was raised, no, they must be always be *SPECIFIC*. Unlike most methods, the format method requires a very cryptic syntax, one which is easily prone to errors. Therefore, it should do some extensive validation to insure the format-spec and the values are compatible. Some might argue that: since format is already slow, that we don't want to slow it down anymore that it already is with validation and type checks -- which are even more concerning when format is used along with print, because print, is *dreadfully* slow! And i agree wholeheartedly. But i assure you, there a design method by which any amount of validation and type checking can be added to any code, one that will not induce *ANY* latency in the "normal execution" of the code. If the maintainer is interested in my solution, he can ask me anytime. -- https://mail.python.org/mailman/listinfo/python-list