Why does str(aList) use repr() on the list's elements?

Max M maxm at mxm.dk
Sun Aug 18 11:27:19 CEST 2002


Jeremy Fincher wrote:
> The subject pretty much says it all -- one would think that the str()
> of a list would use str() on its elements, but it uses repr() instead.
>  Why is this?


Also it is pretty easy to do what you want:

     strRep = ','.join(map(str, theList))

regards Max M




More information about the Python-list mailing list