On 10/18/2012 09:20 PM, Steven D'Aprano wrote: > On Thu, 18 Oct 2012 12:47:48 -0400, Dave Angel wrote: > >> I never use the backslash at end-of-line to continue a statement to the >> next. Not only is it a readability problem, but if your editor doesn't >> have visible spaces, you can accidentally have whitespace after the >> backslash, and wonder what went wrong. > What, you don't read the SyntaxError that you will invariably get? > > > # Python 2.7 and 3.3: > > py> x = 42 + \ > File "<stdin>", line 1 > x = 42 + \ > ^ > SyntaxError: unexpected character after line continuation character > > > > Even if you go back to truly ancient Python 1.5: > > [steve@ando ~]$ python1.5 > Python 1.5.2 (#1, Aug 27 2012, 09:09:18) [GCC 4.1.2 20080704 (Red Hat > 4.1.2-52)] on linux2 > Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam >>>> x = 42 + \ > File "<stdin>", line 1 > x = 42 + \ > ^ > SyntaxError: invalid token > > > Honestly, it's not that hard to diagnose line continuation errors. It's > probably easier to diagnose them than to diagnose missing parentheses. > > The more I hear people dissing line continuation backslashes, the more I > want to use them everywhere.
The context was both C++ and python, and I got into the habit of avoiding the continuation characters in C++, where the compiler usually has a totally stupid error, if any. it's been so long since I've used them, it's quite possible I never tried it in python. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list