semi-concatenated strings

Grant Griffin Grant_member at newsguy.com
Fri May 31 14:01:11 EDT 2002


In article <s1OJ8.16485$4i.1909889 at bin2.nnrp.aus1.giganews.com>, "Terry says...
>
>
>"Grant Griffin" <Grant_member at newsguy.com> wrote in message
>
>> In article <mailman.1022791249.9251.python-list at python.org>, Skip
>says...
>> >At compile time all those strings are concatenated into one long
>string.
>
>> I guess I don't see what's so bad about having to put a "+" at the
>end of
>> each--except maybe that it brings on the need for a continuation
>backslash:
>
>Reread 'at compile time' (hopefully with linear algorithm) - only one
>string object created.
>+ works at runtime with n string objects in n*n time, possibly
>repeatedly (if strings are in loop or function called more than once.
>Quite aside from extra chars.
>

Yeah, I'd thought of that, but didn't bring it up because it goes against my
argument <wink>.  Besides, I wasn't for sure if that was a compile-time thing or
a run-time thing.

In any event this thing seems rather un-Pythonic inasmuch as it violates
four--count 'em: four!--of Tim's design principles:

1) Explicit is better than implicit.  (There's an implicit "+" here.)
2) Errors should never pass silently.  (I discovered this construct via a silent
error I had made: omitting a comma resulted in one fewer string than I needed.)
3) There should be one--and preferably only one--obvious way to do it.  (There
are two ways to concatenate string literals.  But in all fairness, the second
one isn't all that obvious <wink>.)
4) Special cases aren't special enough to break the rules. (One can't
concatenate two string variables without the aid of a "+", so string _literals_
are a special case.)

Then again, as Tim himself once said, the key to any successful philosophy is to
have enough wiggle room to do what you wanted to do anyway.  In that vein, I
suppose one could argue in favor of this that:

1) Beautiful is better than ugly.  (Yes, the trialing "+"'s are a bit ugly,
especially when you add backslashes or extra parens.)
2) Simple is better than complex.  (Yes, there's less typing.  Still, folks who
obsessively conserve typing should be sentenced to a year of Perl--without
parole <wink>.)
3) Although practicality beats purity.  (Yes, as Skip illustrates, this has its
practical uses--though I can't think of any others offhand <wink>.)

not to mention:

4) Namespaces are one honking great idea -- let's do more of those!  (I don't
really know how namespaces come into this, but I just like the word "honking".)

a-proud-member-of-all-the-people-who-can't-be-pleased-all-the-time-ly y'rs,

=g2

_________________________________________________________________________

Grant R. Griffin                                           g2 at dspguru.com
Publisher of dspGuru                               http://www.dspguru.com
Iowegian International Corporation                http://www.iowegian.com




More information about the Python-list mailing list