semi-concatenated strings

Peter Hansen peter at engcorp.com
Thu May 30 22:04:18 EDT 2002


"Delaney, Timothy" wrote:
> 
> > From: Skip Montanaro [mailto:skip at pobox.com]
> >     rows = self.executesql("select cities.city, state, country"
> >                        "    from cities, venues, events, addresses"
> >                        "    where     cities.city like %s"
> >                        "          and events.active = 1"
[snip]
> 
> Just wondering Skip ... why would you write this rather than a triple-quoted
> string?
> 
> 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,))
> 
> which to me looks much cleaner and is much easier to modify.

And which has both embedded "\n" newlines and many more leading
spaces before each line...

-Peter



More information about the Python-list mailing list