On Monday 20 June 2011 00:03:47 Steven D'Aprano wrote: > Lisi wrote: > > I am having problems with line continuation characters. Error message: > > > > SyntaxError: unexpected character after line continuation character > > Then delete it ;) > > Seriously. You have your editor open, right? Go to the line where the > error is reported. It will look something like this: > > blah blah blah \ > > Press the End key. Your editor's blinking insertion point or cursor will > go to the end of the line: > > blah blah blah \ | > > Backspace until the cursor is *immediately* next to the backslash, with > no other characters INCLUDING SPACES after it. > > Which editor are you using? If it is kwrite or kate, it has a setting to > control whether spaces are left at the end of lines, e.g. in kwrite: > > Settings > Configure Editor > Editing > Remove trailing spaces > > > I have succeeded in moving the position of the complaint, but am > > currently well and truly stuck. > > > > I have read up about it and now (I hope!) know what to do about it in > > general, but at one particular point everywhere seems to be wrong. Is > > there any way I can make these wretched continuation characters visible, > > so that I know where and what I am up against? > > Continuation characters are visible. It is a backslash at the very end > of the line. It must not be followed by *anything* -- no comments, no > spaces, nothing. > > >>> x = 23 + \ > > File "<stdin>", line 1 > x = 23 + \ > ^ > SyntaxError: unexpected character after line continuation character > > > If this error message is not clear, would you like to suggest an > improvement?
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, and simply wrote a long line which wrapped. I know how to remove spaces - I just had not got a clue what the message was on about. I found quite a few references to line continuation characters, but nothing that told me what a line continuation character looked like, nor that it must be at the very end of the line. The back-slashes in the script all had other purposes, and I had not realised that where they fell was significant. Thanks for the help. Now to tackle my script. Lisi Lisi _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor