No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:)

Remco Gerlich scarblac-spamtrap at pino.selwerd.nl
Thu May 18 13:52:27 CEST 2000


Martijn Faassen wrote in comp.lang.python:
> François Pinard <pinard at iro.umontreal.ca> wrote:
> > "Magnus Lie Hetland" <mlh at idi.ntnu.no> writes:
> 
> >> This is indeed a bit strange IMO... If I were to join the elements of a
> >> list I would rather ask the list to do it than some string... I.e.
> 
> >>    ['foo', 'bar', 'baz'].join(', ')
> 
> I agree that doing ' '.join(['foo', 'bar', 'baz'] is odd. I'd also agree
> that the list syntax looks more readable, though it's more special case.

I agree that ' '.join(list) is bad, it's for one thing much less readable than
string.join(list, ' ').

But I also like the argument that it shouldn't be a list method, since lists
can hold any kind of object, and adding a method that only makes sense when
all the elements are of one specific type is probably not a good design.
Besides, you want it to work for any type of sequence, not only lists.

Moving string.join into the builtins would be cool, but a lot of people
probably use the identifier already.

So why not simply keep string.join?

-- 
Remco Gerlich,  scarblac at pino.selwerd.nl



More information about the Python-list mailing list