[Baypiggies] Discussion for newbies/beginner night talks

Dennis Reinhardt DennisR at dair.com
Sat Feb 10 01:18:58 CET 2007


At 03:57 PM 2/9/2007, Shannon -jj Behrens wrote:
>On 2/9/07, Dennis Reinhardt <DennisR at dair.com> wrote:
>>This is an optimization and as such may not be the first approach to
>>consider.  All of the code samples I showed used string appends such as
>>
>>         str  = ""
>>          str += "string 1"
>>          str +  "string 2"
>>         ...
>
>#) Use triple quoted strings, and use buffers.

Triple quoted strings are often a poorer solution.

   1) to avoid breaking up the indentation structure, triple quoted
      strings must either have lots of extra white space or must be
      defined globally.  If globally, subroutine level parameter
      substitution is awkward.
   2) Parameter substitution is very awkward for long blocks of
      text.

A common idiom I run up against is defining html in which the user may have 
already entered a value.  So, one might find:

         html += "<input type=text name=xyz value=%s>" % previous("xyz")

and where it is understood that previous() reads the invoking URL for the 
xyz= parameter value.

Doing this in a long triple string is ugly.

Dennis

  ---------------------------------
| Dennis    | DennisR at dair.com    |
| Reinhardt | http://www.dair.com |
  ---------------------------------



More information about the Baypiggies mailing list