list to string

Delaney, Timothy tdelaney at avaya.com
Tue Feb 27 17:58:24 EST 2001


> And, similarly, it's *using* ['a','b','c'] -- not "acting on" 
> it.  It's not
> a mutator.  Not all methods of an object mutate it, and you clearly
> accept that, as you write:
> 
> > OTOH, ''.length() is perfectly fine. It is obvious.
> 
> Since join may use the joiner in a completely polymorphic way, but
> only uses the sequence through a sequence-iteration protocol, it's
> pragmatically _useful_ to have it be a method of the joiner object
> (as Python doesn't do multimethod-like dispatching).  Usefulness
> seems to be a good indicator: if something offends your personal
> sense of purity, but is pragmatically good, then 'practicality beats
> purity' and it might be wise to reconsider your aesthetics:-).

In this case, I think aesthetics and pragmatism are on the same side for me.
The chosen string method for join() is completely non-obvious to me.

At no time did I mean to suggest that the sequence being "acted on" was
mutated. What I meant was the the result of evaluating the expression was a
modification of the sequence i.e. "take the sequence, modify it by
concatenating each element with this string between each element". It is
obvious that the sequence is the object being "acted on".

Whilst you could turn it around, it becomes convoluted and messy. "Take this
string, stick it between each element of this sequence and then concatenate
each element of the sequence into a string". You are still really acting on
the sequence, not the string.

Tim Delaney
Avaya Australia




More information about the Python-list mailing list