Why doesn't join() call str() on its arguments?

Andy Dustman farcepest at gmail.com
Thu Feb 17 22:10:23 EST 2005


Looking at the code, it seems that if it finds a unicode object on the
first pass (the sizing pass), it punts and returns PyUnicode_Join(self,
seq), which is the sequence from above and not necessarily the original
object (orig), and starts over. In the worst-case scenario, you have a
long sequence of strings with one unicode string at the end...

Actually, I guess I'm a little surprised that str.join(arg) doesn't
require arg to be an iterator that returns str instances.
unicode.join(arg) can afford to be a little more flexible. I wonder how
common it is to pass a mixture of str and unicode to str.join().




More information about the Python-list mailing list