semi-concatenated strings
Skip Montanaro
skip at pobox.com
Thu May 30 22:04:23 EDT 2002
>> rows = self.executesql("select cities.city, state, country"
>> " from cities, venues, events, addresses"
>> " where cities.city like %s"
>> " and events.active = 1"
>> " and venues.address = addresses.id"
>> " and addresses.city = cities.id"
>> " and events.venue = venues.id",
>> (city,))
Tim> Just wondering Skip ... why would you write this rather than a
Tim> triple-quoted string?
Habit.
Tim> Of course, I also would have bound the SQL to a name first ...
Doesn't make sense to me. Each sql statement is substantially different
from all the rest and is only single use. The particular file I pulled that
out of contains 118 calls to the executesql method, 98 of which use string
literals for the SQL statement.
Tim> I've yet to find a place where I've had a use for concatenating
Tim> string literals.
To each his own.
Skip
More information about the Python-list
mailing list