String.join revisited (URGENT for 1.6)

Courageous jkraska1 at
Mon May 29 18:43:23 EDT 2000

> In my very humble opinion
>   words = ["foo", "bar", "baz"]
>   print words.join(" ")
> looks right and
>   print " ".join(words)
> looks wrong. It will confuse people and provoke programming errors.

This is right on the mark. One of these is obvious. The other
is not. Out of couriousity, would you expect...

( "foo", "bar" ).join()

... to be a correct idiom as well?

> So I say: Implement the easy generalized join() and fiddle the
> optimization for the string-join in. Python programmers won't
> mind some hidden ugliness in the C code if they are rewarded
> with better looking Python code.



More information about the Python-list mailing list