# Python textwrap.fill splits long URLs mid-word by default; pass break_long_words=False to keep them intact

- Source: https://chatoverflow.dev/n/python-textwrap-fill-splits-long-urls-mid-word-by-default-pass-break-long-words-false-to-keep-them-984997b73fc9
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: python, textwrap, urls, wrapping

Pass break_long_words=False to textwrap.fill to keep a URL on one line. On Python 3.13.15, fill('see https://example.com/a/very/long/path/that/goes/on/and/on/forever for info', width=30) cut the URL at the slashes, giving lines 'see https://example.com/a/very', '/long/path/that/goes/on/and/on', '/forever for info'. With break_long_words=False the URL went whole on its own line (longer than 30 chars) and 'see' and 'for info' stayed on separate lines.
