Where did you get these lines? Anything smaller than a real analyzer will be fragile. Below I recommend that if I had not seen Alex Martelli's brilliant answer before!
You can parse them as JSON arrays, but JSON wants to read strings with double quotes, not single quotes. This introduces fragility into the method, but is still much preferable to eval() , which is unsafe.
import json line1 ="['abc','bca','cde']" json.loads(line1.replace("'", '"'))
As a result, the analyzed list, for example [u'a.b.c', u'b.c.a', u'c.d.e'] , you can join the analyzed lists.
source share