osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Textwrap doesn't honour NO-BREAK SPACE


"Steve D'Aprano"  wrote in message 
news:59cde998$0$14935$b1db1813$d948b532 at news.astraweb.com...

On Fri, 29 Sep 2017 03:55 pm, Terry Reedy wrote:

>> Expected result:
>>
>>
>> Lorum ipsum dolor sit amet, consectetur adipiscing elit
>> ZZZ ZZZ sed do euismod tempor incididunt ut labore et
>> dolore magna aliqua.
>
> On Windows 10, I get this on 2.7, 3.5, 3.6, 3.7.
>
>> 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.

> Sorry Terry, it isn't clear to me which result (expected, or actual) is 
> "this"
> in your comment.

I was also unsure, so to double-check myself I ran this from the prompt 
(Windows 10), not from the interpreter -

C:\Users\User>type aib\aib\test_db100.py

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()
print(textwrap.fill(text, 59))

C:\Users\User>py -3.5 aib\aib\test_db100.py

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

C:\Users\User>py -3.6 aib\aib\test_db100.py

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

It confirms that the problem was there in 3.5, but is fixed in 3.6.

Frank Millman