Representing tuples in strings

Graham Ashton graz at
Tue Oct 30 01:53:18 CET 2001

I'm looking to convert the tuple:

  ('string1', 3, 'string2')

to the string representation:

  'string1', 3, 'string2'

without resorting to a regular expression.

So far the nearest I've managed to get to is to have quotes round the
whole thing, but not around the strings themselves. I suppose what I want
here really is some better function to pass into map(). Maybe...

  >>> mytup = ('string1', 3, 'string2')
  >>> ", ".join(map(str, mytup))
  'string1, 3, string2'

Any thoughts? It's not exactly going to make the difference between life
and death in my application (it's for log files), but I'd really like to
learn some map/lambda tricks.



More information about the Python-list mailing list