For review: PEP 308 - If-then-else expression

Christian Tismer tismer at tismer.com
Sun Feb 9 17:17:16 EST 2003


Matthew Dixon Cowles wrote:
...

>>  ','.join(lines)
>>
>>In what direction does it reads?
> 
> 
> As Alex points out, execution order does match reading order in this
> case. If it's un-Pythonic it must be for another reason. And I'll
> admit that I found it weird as heck the first time I saw it. But I
> think that the logic for doing it that way is compelling: Lots of
> things can be indexed. Lists, tuples, strings, and many user classes
> can be indexed. If join() were a method of the thing being indexed, it
> would have to be implemented in many places. As a method of the
> separator, it can be implemented only once.

Absolutely.
If one follows the object paradigm consequently,
and that was the intent of the new string methods,
then this decision is completely logical.
The seperator is the only known single object
in this play, that can provide the method.

Bit this is debatable, since the singularity of
the seperator is just an incidence.
Consider for example an operation that intersperes
string representations by different decoration, maybe
with something special at the beginning/end, then
the principle breaks down resp. doesn't carry that
far. You would have to leave the objec domain
and introduce string functions, again.

I could imagine that they could have decided not to
make join a string method at all, but split()
strongly suggested it. If somebody wants to discuss
*that* please make sure to do it in another thread :-)

ciao - chris

-- 
Christian Tismer             :^)   <mailto:tismer at tismer.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  pager +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/







More information about the Python-list mailing list