[Baypiggies] Discussion for newbies/beginner night talks

Aahz aahz at pythoncraft.com
Sat Feb 10 15:24:34 CET 2007

On Fri, Feb 09, 2007, Dennis Reinhardt wrote:
> At 05:05 PM 2/9/2007, Paul McNett wrote:
>>I respectfully disagree. Take this example:
>>class MyBizobj(...):
>>         def getCustomerInfo(self, cust_id):
>>                 sql = """
>>select customers.name as name,
> This starts with an empty line.  I believe this can be changed by
>                  sql = \
> """select customers.name as name,
> Which then breaks up the SQL, albeit only slightly.
> My point had to do with "breaking up the indentation structure" and I think 
> you have illustrated my point.
> You illustration does not show how a long triple quoted string gets 
> supplied with parameters.  Stylistically, I often prefer substituting 
> parameters on a line by line basis because there is better locality, making 
> the code easier to understand and read.

Strings like SQL and HTML that do not normally get presented to the user
don't need to care about whitespace AT ALL.  Here's what I normally do at

    sql = """
        select c.name 
        from customers c
        where c.activation_date > %s
        """ % db.sql_repr(activation_date)

The SQL itself may be further indented as needed for clarity
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

"I disrespectfully agree."  --SJM

More information about the Baypiggies mailing list