.join() question

Simon Bayling sfb at alysseum.com
Wed Jul 9 22:16:25 CEST 2003


I would risk a guess that this comes under the "explicit is better than 
implicit" guideline.

''.join([str(i) for i in lst])

Explains to everyone that you know the list has some non-string things, 
and you intend them to be str()'ified.

Intention-guessingly yours,
Simon.

"drs" <drs at ecp.cc> wrote in
news:eo_Oa.14415$BM.4645038 at newssrv26.news.prodigy.com: 

> why does
> 
>>>> ''.join(lst)
> 
> not automatically do
> 
>>>> ''.join([str(i) for i in lst])
> 
> ?  That is, is there ever a time when one does not want .join to make
> everything into a string?  This seems like reasonable default
> behavior, but maybe I'm missing something?
> 
> -doug
> 
> 
> 





More information about the Python-list mailing list