[Python-Dev] str.dedent

Noam Raphael noamraph at gmail.com
Sat Nov 19 21:48:00 CET 2005


On 11/19/05, Steven Bethard <steven.bethard at gmail.com> wrote:
> > You are missing an important point here: There are intentionally no line
> > breaks in this string; it must be a single line, or else showerror will
> > break it in funny ways. So converting it to a multi-line string would
> > break it, dedent or not.
>
> Only if you didn't include newline escapes, e.g.::
>
>     msg = textwrap.dedent('''\
>         IDLE's subprocess can't connect to %s:%d.  This may be due \
>         to your personal firewall configuration.  It is safe to \
>         allow this internal connection because no data is visible on \
>         external ports.''' % address)
>

Unfortunately, it won't help, since the 'dedent' method won't treat
those spaces as indentation.

But if those messages were printed to the standard error, the line
breaks would be ok, and the use case valid.

Noam


More information about the Python-Dev mailing list