Confusing textwrap parameters, and request for RE help

Grant Edwards grant.b.edwards at gmail.com
Thu Mar 26 15:20:47 EDT 2020


On 2020-03-26, Peter J. Holzer <hjp-python at hjp.at> wrote:
>> Actually, fixed width fonts are easy to justify, you just add additional 
>> space between words through the line.
>
> Yes. It's easy to do it wrong and impossible to do it right :-)
>
> (BTDT)
>
> The problem is that you can only insert an integral number of spaces und
> the number of spaces you need to insert is rarely a multiple of the
> number of gaps between words. So you get uneven spacing, which looks
> horrible.

That was always an interesting freshman programming homework
problem. But you're right, nobody in their right mind would actually
want to generate real output that way.  Ragged-right is far, far
better than using fixed-width font justified with extra spaces
scattered in.

--
Grant





More information about the Python-list mailing list