The irony

Ned Batchelder ned at nedbatchelder.com
Tue May 10 14:33:41 EDT 2016


On Tuesday, May 10, 2016 at 2:03:47 PM UTC-4, DFS wrote:
> Which is the "one obvious way" to do it?
> 
> I liked:
> 
> sSQL =  "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"
> 
> 
> but it's frowned upon in PEP8.

I would use a way you didn't show:

    sSQL = """
        line1
        line2
        line3
        """

SQL doesn't mind the extra whitespace, so don't worry about the leading
spaces.  If you really wanted to control it tightly, I would use (and have
used):

    sSQL = textwrap.dedent("""\
        line1
        line2
        line3
        """)

--Ned.



More information about the Python-list mailing list