Python is, in general, fairly forgiving.
I disagree with the learning path some books suggest, that seems to always be aimed towards instant gratification, but tend to put idiomatic and string tricks in too early, forsaking programming principles.
In the second case you mention, the \ in python means “interpret the next line as if it was indented the same of the one you started parsing from”.
In the case you mention having it or not having it makes no difference, because the interpreter already knows to keep concatenating until it meets your closing ), and it doesn’t need new line and tabs to identify scoping, therefore will ignore it and not error.
It would if you had it inside a scope determined by tabbing in (an if in example), and didn’t indent the following lines, in which case the backslash would instruct the interpreter to ignore that mistake (so that you can occasionally break the tabbing syntactical rule in favour of readability).
It’s something that doesn’t really have a place in that example, same as escaping an apostrophe that, within a string like that, will be read just fine, since you are enclosing the string within double quotation marks anyway.
In the first case, to understand the difference this is a better example:
print 'doh\''
print 'doh''
The first will run, because the interpreter finds the backslash, and knows to interpret the next character as a literal, and therefore doesn’t think it’s the end encolsure for the string.
The second line will error because unescaped, that apostrophe will be interpreted as the closure of your string, and te next one will be syntactically incorrect.
For the second example this would explain the situation better:
if 1:
print "blah"
print "zomg"
else:
print "umpf"
Will error, because print being indented back takes the interpreter outside the if scope, and then an else is found without any pending if scope to merge it to.
If for some reason (highly articially in this case) you wanted to break Python’s formatting rules, you could write it like this:
if 1:
print "blah";\
print "zomg"
else:
print "umpf"
In this case the ; at the end of the first print tells Python that that line is basically done, the backslash tells it that the next line, regardless of indentation, should be interpreted within the scope of the previous one (tabbed in once), which means the above, interpretation wise, reads like:
if 1:
print "blah"
print "zomg"
else:
print "umpf"
Edit: to detail the blurb about statement VS function call in print (something that changes from py 2.4 to 3k, and was backported for future compatibility in 2.5 and on)
The first example might have made sense with Python’s old print, which was a pseudo statement and didn’t require parenthesis to call, it will not error the way the author intended it to error if you removed the backslashes with parentheses though.
It would if you used
print "blah" + " blah" +
"blah"
whereas
print "blah" + " blah" +\
"blah"
will run fine.
This is only valid in pre py3k though, and when books are re-edited from 2.x for 3k instead of being rewritten, crap like that makes it in, and confuses the hell out of neophytes.
IMO, get py 2.7 and a pre 3k O’Reilly’s “learning python”. Best money you could spend on yourself if you’re enjoying python. It’s a book that doesn’t make the mistake of treating the reader as one of two categories chosen between “drooling idiot in need of condescension” and “proficient programmer that’s just picking another language up”, and caters to the middle ground of “normal to smart people who did some homework but aren’t pros already who want to learn programming and python at the same time”.