[Tutor] How to break long lines?

Jim Byrnes jf_byrnes at comcast.net
Fri Feb 22 22:26:39 CET 2013


I am cleaning up my code and have a number of sqlite3 execute statements 
that extend far past 80 characters.

 From my reading implicit line joining with (), [] or {} seems to be the 
preferred method, but

cur.execute('SELECT Account FROM pwds WHERE Category=? ORDER BY Account
	COLLATE NOCASE', cat)

gives this error:

jfb at jims1204:~/MyProgs/passwords$ python passwords.py
   File "passwords.py", line 50
     cur.execute('SELECT Account FROM pwds WHERE Category=? ORDER BY Account
                                                                           ^
SyntaxError: EOL while scanning string literal

Using a \ seems to be out of favor but it works in this case.

cur.execute('SELECT Account FROM pwds WHERE Category=? ORDER BY Account\
	COLLATE NOCASE', cat)
# no error.

What am I not understanding about implicit line joining?

Thanks,  Jim



More information about the Tutor mailing list