Confusing textwrap parameters, and request for RE help

Chris Angelico rosuav at gmail.com
Tue Mar 24 05:08:31 EDT 2020


On Tue, Mar 24, 2020 at 4:36 AM Dieter Maurer <dieter at handshake.de> wrote:
>
> Chris Angelico wrote at 2020-3-23 06:00 +1100:
> >When using textwrap.fill() or friends, setting break_long_words=False
> >without also setting break_on_hyphens=False has the very strange
> >behaviour that a long hyphenated word will still be wrapped.
>
> Having worked with `TeX`, I am familiar that hyphens indicate
> word locations favorable to line breaks. Therefore, I understand
> that one wants a way to control whether or not breaks are allowed
> at hyphens, even if words should not be broken normally.
>
> Apparently, "break_on_hyphens" adds hyphen as a word delimiter.
> With this notion, the behavior can be understood.

Well um... yes. I think we know that hyphens do indicate word-split
points. That's not really in question. But if I say "don't break long
words", and then long words get broken at hyphens, that's surprising.

ChrisA


More information about the Python-list mailing list