[Tutor] problem with back slash

Mats Wichmann mats at wichmann.us
Wed Feb 23 15:40:54 EST 2022


On 2/23/22 12:37, Alex Kleider wrote:
> I've written myself a little utility that accepts a text file which
> might have very long lines and returns a file with the same text but
> (as much as possible) with the lines no longer than MAX_LEN
> characters. (I've chosen 70.)
> It seems to work except when the the source file contains back
> slashes! (Presence of a back slash appears to cause the program
> to go into an endless loop.)
> I've tried converting to raw strings but to no avail.

If you just want to solve the problem, see the textwrap module from the
standard library.

I'm sure someone will look at and make comments on the code...




More information about the Tutor mailing list