[ANN] istring interpolated strings release 1.0

Steven D. Arnold stevena at neosynapse.net
Fri Jan 25 11:00:33 EST 2002


Hi Steve,

On Friday, January 25, 2002, at 9:04:09 AM, Steve Holden wrote:

SH> As far as I'm concerned, (1) is rather clearer, since it isn't apparent to
SH> me that in (2) the

SH>     AND    name = $.name

SH> portion will become'

SH>     AND name = 'namevalue'

SH> Unless, of course, that's a typo.

Readability is a tough area in which to satisfy everyone, since
whether something is readable is largely a matter of opinion.  My
feeling is that the istring syntax, once understood, is as readable as
the % syntax, once understood.  I suspect that a person who didn't know
the % syntax might be completely confused by its many options.  My
criteria for readability here is not so much that istring syntax must
be totally obvious at first glance, but rather that you can quickly
learn it, and having learned it, the meaning is immediately obvious.
It does seem to me that once you are familiar with both the istring
syntax and the % syntax, it will generally be easier to absorb the
meaning of an istring-style string; YMMV, of course.

Nontheless, you may wish to have other alternatives and I'd like to
provide them to you if they fit reasonably within the mission of
istring.  I could add a function like this:

    AND name = &squote(name)

dquote quould use double-quotes.  Then you can use the terse syntax
above or a perhaps more readable function-like syntax.  I'll
implement this if someone asks for it; also open to other suggestions.

SH> Unfortunately this example needs rewriting, as you are constructing an
SH> istring from the result of a formatting operation rather than formatting on
SH> an istring.

Good point.  I'll fix that.

SH> Also bear in mind that, which it is necessary to use string interpolation
SH> for certain portions of statements (such as the table in your example
SH> above), it is actually _much_ more efficient to use the DB API's parameter
SH> substitution mechanisms to parameterize query values.

Excellent point.  Seems like it ought to be easy to extend istring for
database purposes to do this.

>> [...]
SH> Despite these minor misgivings, congratulations on putting something usable
SH> and worthwhile out for Python users.

Thanks, I appreciate your feedback.

-------------------------------------------------------------- 
Steven D. Arnold                                    Neosynapse
stevena at neosynapse.net                        Managing Partner
AIM: abraxan                       MSN: neosynapse at hotmail.com






More information about the Python-list mailing list