Textwrap doesn't honour NO-BREAK SPACE

Steve D'Aprano steve+python at pearwood.info
Fri Sep 29 01:25:09 EDT 2017


I don't have Python 3.6 installed, can somebody check to see whether or not it
shows the same (wrong) behaviour?


import textwrap
text = ('Lorum ipsum dolor sit amet, consectetur adipiscing'
        ' elit ZZZ\xa0ZZZ sed do euismod tempor incididunt'
        ' ut labore et dolore magna aliqua.')
print(textwrap.fill(text, 59))



Expected result:


Lorum ipsum dolor sit amet, consectetur adipiscing elit
ZZZ ZZZ sed do euismod tempor incididunt ut labore et
dolore magna aliqua.


Actual result in Python 3.5 and older:


Lorum ipsum dolor sit amet, consectetur adipiscing elit ZZZ
ZZZ sed do euismod tempor incididunt ut labore et dolore
magna aliqua.


I'm pretty sure this is a bug.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.




More information about the Python-list mailing list