[Tutor] line continuation characters

Alan Gauld alan.gauld at btinternet.com
Mon Jun 20 10:06:15 CEST 2011


"Lisi" <lisi.reisz at gmail.com> wrote

> It is not the error message that is unclear, it was the state of my 
> knowledge.
> I did not know that \ was a line continuation character,

I sympathise.
I had been programming for about 5 years before I came
across line continuation characters. For me it was while
reviewing someone's code, and they used them extensively.

> I found quite a few references to line continuation characters,

Wikipedia is usually your friend for looking up things like this.
In this case it would have told you that the characters used
depend on the language and specifically:

Backslash as last character of line

  a.. C and C++ preprocessor
  b.. Python
  c.. Ruby

>  The back-slashes in the script all had other purposes,

Which is one reason I try not to use them, because
backslashes already have another purpose, they can
be confusing. You can usually avoid using them by
incorporating parentheses or brackets in the line and
breaking before the closing bracket.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list