[Tutor] Trailing spaces affect output in a way I don't understand.
eryksun
eryksun at gmail.com
Sun Dec 16 20:55:27 CET 2012
On Sat, Dec 15, 2012 at 11:55 PM, boB Stepp <robertvstepp at gmail.com> wrote:
> On Sat, Dec 15, 2012 at 10:43 PM, Steven D'Aprano <steve at pearwood.info> wrote:
>
>> Two solutions are:
>>
>> * Add a space to the end of the backslashes. The space is invisible, and
>> some editors may strip it out, so this is a fragile solution.
>
> In my efforts to understand what was going on, I discovered that
> PyScripter's (My current editor that I am playing around with.)
> default setting is to trim all line-ending spaces, running into
> exactly what you say.
>From PEP 8:
Don't write string literals that rely on significant trailing whitespace.
Such trailing whitespace is visually indistinguishable and some editors
(or more recently, reindent.py) will trim them.
>> * Change the string to a raw string, r"""...""" so that backslash
>> interpolation is turned off.
>
> And I suppose I could also escape the backslash (\\), too. But your
> suggestion sounds the best.
You could also store the string in a text file or database.
P.S. For anyone using Gmail's new in-line reply box, the class to
style it with a monospace font is .LW-avf.
More information about the Tutor
mailing list