Grant Edwards ha scritto: >> One solution: >> >>>>> s = '(a, b, "c", d, "e")' >>>>> print [x.strip('" ') for x in s.strip('()').split(',')] >> ['a', 'b', 'c', 'd', 'e'] > > That fails when a quoted string contains commas: > >>>> s = '(a, b, "c", d, "e,f,g")' >>>> print [x.strip('" ') for x in s.strip('()').split(',')] > ['a', 'b', 'c', 'd', 'e', 'f', 'g'] > > I presume the correct result would be > > ['a', 'b', 'c', 'd', 'e,f,g'] >
Uhm, agree. I supposed quoted strings were presumed to be 'trivial'. Definitely csv module is the solution :-) -- http://mail.python.org/mailman/listinfo/python-list