String.join revisited (URGENT for 1.6)

Courageous jkraska1 at san.rr.com
Tue May 30 02:09:17 CEST 2000


> > > >   words = ["foo", "bar", "baz"]
> > > >   print words.join(" ")
> >
> > > print ( "foo", "bar" ).join(" ")
> >
> > I've thought about this for a bit, and it's quite clear to me that
> > these idoms are the natural representation for this. Whether or
> > not their implementation in python is easily/optimally acheived
> > is another issue altogether, but this representation is natural
> > and, IMO, right one.
> 
> ...and here we go, back to the beginning of this thread...
> 
> as people have pointed out a couple of hundred times in this thread,
> lists and tuples are *heterogeneous* containers. you can put *any*
> kind of Python object in them, not just strings.

That's true enough. It misfortunately really doesn't
make sense to do that without uniform container types,
unless, of course, you just threw an exception if an
object existed in the container without the appropriate
method.

I really don't find much wrong with string.join() myself,
although " ".join is clearly madness. :)-


C/



More information about the Python-list mailing list