Hi William, On Thu, Apr 15, 2010 at 10:02 PM, William Stein <wst...@gmail.com> wrote:
<SNIP> > That is another issue. It doesn't cause any trouble in python, so it > doesn't concern me. I have an Emacs keyboard shortcut that removes all trailing white spaces in a file. When I started out with Python programming, I wrote a statement that spans more than 80 characters wide. To break that statement up into a multiline statement, I used the backslash character. When I ran the file through Python and Sage, an error came out reporting about unexpected characters. Some digging revealed that I had trailing white spaces after the backslash. To illustrate what I mean, consider the following conditional: [mv...@sage ~]$ cat demo.sage if 3 > 2 and \ 2 == 2: print True [mv...@sage ~]$ sage demo.sage File "demo.py", line 4 if _sage_const_3 > _sage_const_2 and \ ^ SyntaxError: unexpected character after line continuation character Note that there is a trailing white space after the line "3 > 2 and \". PEP008 [1] recommends using parentheses for multiline statements. So the above conditional could be written as: [mv...@sage ~]$ cat demo.sage if (3 > 2 and 2 == 2): print True [mv...@sage ~]$ sage demo.sage True Parentheses have implicit continuation, so it doesn't matter if you have trailing white spaces after "if (3 > 2 and". [1] http://www.python.org/dev/peps/pep-0008/ -- Regards Minh Van Nguyen -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org