[Python-Dev] PEP 460 reboot
ethan at stoneleaf.us
Tue Jan 14 21:13:31 CET 2014
On 01/14/2014 10:52 AM, Guido van Rossum wrote:
> Which reminds me. Quite a few people have spoken out in favor of loud
> failures rather than silent "wrong" output. But I think that in the
> specific context of formatting output, there is a long and IMO good
> tradition of producing (slightly) wrong output in favor of more strict
> behavior. Consider for example what to do when a number doesn't fit in
> the given width. Would you rather raise an exception, truncate the
> value, or mess up the formatting?
One more data point to consider: When the binary format has strict rules on how much space a data-point is allowed,
then failure is the only appropriate option.
In Py2, because '%15s' can actually take 17 characters, I have to use '%15s' % data_value[:15] everywhere.
I'm not suggesting we change how that portion works, as it would then be, I think, too different from both Py2 behavior
as well as current str behavior, but likewise adding in single quotes would of no help to me. Loud failure so I can
easily see where I forgot the .encode() would be much more helpful.
More information about the Python-Dev