expand tuple in string

Erik Max Francis max at alcyone.com
Wed Oct 15 17:40:02 EDT 2003


Ansgar Wollnik wrote:

> I'd like to expand a tuple into a string (to use this for a
> MySQL-Select).
> 
> result=""
> tuple=('one','two','three')
> for element in tuple:
>         result=result+","+element
> 
> But this doesn't work. What can I do to get a string like this:
> 
> result="one, two, three"

Try:

	', '.join(myTuple)

-- 
   Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
 __ San Jose, CA, USA && 37 20 N 121 53 W && &tSftDotIotE
/  \ In our family we don't divorce our men -- we bury them.
\__/  Ruth Gordon




More information about the Python-list mailing list