[Python-ideas] with statement syntax forces ugly line breaks?

Georg Brandl g.brandl at gmx.net
Thu Sep 9 14:14:50 CEST 2010

Am 09.09.2010 07:49, schrieb Mark Summerfield:
> Hi Nathan,
> On Wed, 8 Sep 2010 13:00:25 -0400
> Nathan Schneider <nathan at cmu.edu> wrote:
>> Mark,
>> I have approached these cases by using the backslash
>> line-continuation operator:
>> with FakeContext("a") as a, \
>>    FakeContext("b") as b:
>>    pass
> Yes, of course, and that's the way I've done it. But it seems a pity to
> do it this way when the documentation explicitly discourages the use of
> the backslash for line continuation:
> http://docs.python.org/py3k/howto/doanddont.html
> (look at the very last item)

Which is actually factually incorrect and should be rewritten.  The only
situation where stray whitespace after a backslash is valid syntax is
within a string literal (and there, there is no alternative).

So at least the "stray whitespace leads to silently buggy code" reason
not to use backslashes is wrong.


Thus spake the Lord: Thou shalt indent with four spaces. No more, no less.
Four shall be the number of spaces thou shalt indent, and the number of thy
indenting shall be four. Eight shalt thou not indent, nor either indent thou
two, excepting that thou then proceed to four. Tabs are right out.

More information about the Python-ideas mailing list