11 May
2013
11 May
'13
8:28 a.m.
On Sat, May 11, 2013 at 1:12 PM, Alexandre Fayolle ML
I'll typically use such wrapping on SQL statements:
cursor.execute('SELECT foo, bar FROM mytable '
'WHERE baz = %(baz)s',
{'baz': baz})
I prefer to use string concatenation using the 'addition' operator, which
makes it more explicit: cursor.execute('SELECT foo, bar FROM mytable ' + 'WHERE baz = %(baz)s', {'baz': baz}) At compile time, they are implemented in the same way:
dis.dis(lambda: 'a' + 'a') 2 0 LOAD_CONST 2 ('aa') 3 RETURN_VALUE dis.dis(lambda: 'a' 'a') 2 0 LOAD_CONST 1 ('aa') 3 RETURN_VALUE
Rigel