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?

The problem is the line break. Single delimited (quote or double quote) strings
can only stay on one line (unless using the \ hack). You can easily solve this 
problem in your case by using triple delimited strings. 

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


~Ramit


This email is confidential and subject to important disclaimers and
conditions including on offers for the purchase or sale of
securities, accuracy and completeness of information, viruses,
confidentiality, legal privilege, and legal entity disclaimers,
available at http://www.jpmorgan.com/pages/disclosures/email.  
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to