OkaMthembo wrote:
Doesn't backslash also escape the newline? Thought i saw something to that
effect in the tutorial.

It does, but only inside the .py file. It has no effect when you run the 
program.

Its purpose is to allow you to break long lines, for example

if long_function_name(a) == long_function_name(b) \
        and long_function_name(c) == long_function_name(d) \
        and long_function_name(e) == long_function_name(f):
    # do something if all three equalities hold

note that you can place the \<NEW-LINE> break anywhere.
Some people like the following layout

if long_function_name(a) == long_function_name(b) and \
   long_function_name(c) == long_function_name(d) and \
   long_function_name(e) == long_function_name(f):
    # do something if all three equalities hold

The conditions now nicely line up, making it easier to read. The down side (in my opinion) is that the difference in indent is really small.


Sincerely,
Albert
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to