[Python-ideas] Descouraging the implicit string concatenation
Chris Angelico
rosuav at gmail.com
Wed Mar 14 18:31:02 EDT 2018
On Thu, Mar 15, 2018 at 9:06 AM, Kyle Lahnakoski
<klahnakoski at mozilla.com> wrote:
> I did use implicit concatenation for a long SQL statement, and a few
> long error messages, but the byte savings is not worth the increased bug
> density.
>
>> self.db.execute(
>> "CREATE TABLE files (" +
>> " bucket TEXT," +
>> " key TEXT," +
>> " name TEXT," +
>> " last_modified REAL," +
>> " size INTEGER," +
>> " annotate TEXT, " +
>> " CONSTRAINT pk PRIMARY KEY (bucket, name)" +
>> ")"
>> )
>
> is almost identical to
>
>> self.db.execute(
>> "CREATE TABLE files ("
>> " bucket TEXT,"
>> " key TEXT,"
>> " name TEXT,"
>> " last_modified REAL,"
>> " size INTEGER,"
>> " annotate TEXT, "
>> " CONSTRAINT pk PRIMARY KEY (bucket, name)"
>> ")"
>> )
>
> It looks like I am in the market for a linter that prevents implicit
> string concatenation!
Even better:
self.db.execute("""
CREATE TABLE files (
bucket TEXT,
key TEXT,
name TEXT,
last_modified REAL,
size INTEGER,
annotate TEXT,
CONSTRAINT pk PRIMARY KEY (bucket, name)
)
""")
ChrisA
More information about the Python-ideas
mailing list