[Baypiggies] Discussion for newbies/beginner night talks

Paul McNett p at ulmcnett.com
Sat Feb 10 17:14:16 CET 2007

Aahz wrote:
> On Fri, Feb 09, 2007, Dennis Reinhardt wrote:
>> 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.

How about this contrived example:

def getHeader(self, **kwargs):
	html = """<!-- BOF header -->

	<meta name="description" value="%(title)s">
	<meta name="keywords" value="%(keywords)s">


<!-- EOF header -->
	return html % kwargs

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

I think that with longish triple-quoted strings, ignoring the code 
indentation is the best. But that's me.

pkm ~ http://paulmcnett.com

More information about the Baypiggies mailing list