The irony
Lorenzo Sutton
lorenzofsutton at gmail.com
Wed May 11 06:17:57 EDT 2016
On 10/05/2016 20:03, DFS wrote:
> "There should be one-- and preferably only one --obvious way to do it."
>
> https://www.python.org/dev/peps/pep-0020/
"Explicit is better than implicit."
What is your use case and scenario? :-)
Maybe it's better to write a function to automatise this so that if
instead of "line 1\n ..." you want "banana 1~banana 2~ " etc. you can
simply change parameters?
That said join and list comprehensions would also come to mind, but not
sure how "obvious" that is...
Lorenzo.
>
>
> -----------------------------------
> sSQL = "line 1\n"
> sSQL += "line 2\n"
> sSQL += "line 3"
> -----------------------------------
> sSQL = ("line 1\n"
> "line 2\n"
> "line 3")
> -----------------------------------
> sSQL = "\n".join([
> "line 1",
> "line 2",
> "line 3",
> ])
> -----------------------------------
> sSQL = """line 1
> line 2
> line 3"""
> -----------------------------------
> sSQL = """\
> line 1
> line 2
> line 3"""
> -----------------------------------
> sSQL = "line 1\n" \
> "line 2\n" \
> "line 3"
> -----------------------------------
>
>
> 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.
>
>
More information about the Python-list
mailing list