[Python-ideas] with statement syntax forces ugly line breaks? (original) (raw)

Terry Reedy tjreedy at udel.edu
Thu Sep 9 22:55:15 CEST 2010


On 9/9/2010 8:14 AM, Georg Brandl wrote:

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, _ Adding a space makes the following a SyntaxError. No silent error here.

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)

If no one uses \ for end of line escape, it should be removed ... But I am not suggesting that.

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. Georg

-- Terry Jan Reedy



More information about the Python-ideas mailing list