On 02/22/2013 04:26 PM, Jim Byrnes wrote:
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@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
>
> _______________________________________________
> Tutor maillist - Tutor@python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
>

There are a few ways:

"abc \
xyz"

("abc " \
"xyz")

("abc "
"xyz")


The last ones work because two string literals next to each other
are combined:

'abc' 'xyz' == 'abcxyz'

 -m


--
Lark's Tongue Guide to Python: http://lightbird.net/larks/

The press, the machine, the railway, the telegraph are premises whose
thousand-year conclusion no one has yet dared to draw.  Friedrich Nietzsche

_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to