Join equivalent for tuples of non-strings?
ulope at gmx.de
Thu Sep 18 22:30:36 CEST 2003
"Peter L. Buschman" <plb at iotk.com> schrieb im Newsbeitrag
news:1a884f4a.0309181000.749eb8a1 at posting.google.com...
> I'm trying to think in Python, but am stumped here...
> What is the equivalent for the following if you are dealing with a tuple
> of non-strings?
> >>> import string
> >>> foo = ( '1', '2', '3' )
> >>> string.join( foo, '.' )
> With a tuple of integers, this fails with a traceback as below:
> >>> bar = ( 1, 2, 3 )
> >>> string.join( bar, '.' )
foo = (1,2,3,4,5,6)
".".join([str(x) for x in foo])
More information about the Python-list