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

Nick Coghlan ncoghlan at iinet.net.au
Thu Feb 17 09:26:41 EST 2005


news.sydney.pipenetworks.com wrote:
> I'm not sure if this has been raised in the thread but I sure as heck 
> always convert my join arguments using str(). When does someone use 
> .join() and not want all arguments to be strings ? Any examples ?

When the list argument already contains only strings, conversion is redundant.

Anyway, automatic conversion of the argument list elements *was* tried around 
August of last year, despite some concerns about it being too magical. However, 
the interaction between string, unicode, subclasses of same, __str__, __repr__, 
__unicode__ and everything else made it impossible to come up with behaviour 
that was clearly 'better' than the status quo (every idea we considered ended up 
resulting in quirky behaviour at some point), so things never progressed to a 
formal patch.

The explicit use of map() or LC was kept as the least bad of the available options.

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at email.com   |   Brisbane, Australia
---------------------------------------------------------------
             http://boredomandlaziness.skystorm.net



More information about the Python-list mailing list