On 02/17/2015 02:12 PM, boB Stepp wrote:
See
https://docs.python.org/3.4/reference/lexical_analysis.html#string-and-bytes-literals
At this point in the text he is not talking about raw literal strings.
I examined the author's source and he has obviously inserted at least
one space between each use of a backslash at the end of a line and the
EOL terminating characters.
Then he's teaching you wrong. Backslash followed by space is not a valid
escape sequence, and to do it at the end of line is particularly odious.
I wouldn't even suggest it in real code, never mind in something
that's published on paper.
The docs admit that the invalid escape sequences behave differently than
C, in that the backslash is retained. I think it should be a syntax
error to have an invalid sequence.
If the backslash immediately precedes the newline, then the two
characters both get eaten, and the two lines are combined into one.
That can be useful if you want to define a string that's too long to fit
in your source file.
I would never intentionally make any trailing whitespace in source code
be significant. And years ago I used an editor that routinely deleted
any such invisible characters. From the rest of your message, it looks
like IDLE may have that behavior.
He did not do this with the "Game" portion
of the code, which did not make any use of "\" . When the file is run
everything behaves as desired. But if, as my son did, you leave no
spaces between the last backslash and the EOL termination characters,
then the problem behavior occurs.
--
DaveA
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor