Just for fun, here is a parser written with pyparsing. It treats newlines as whitespace so it will work with the split data you posted. http://pyparsing.wikispaces.com/
data = '''(39577484, 39577692) [['NM_003750']] (107906, 108011) [['NM_002443']] (113426, 113750) [['NM_138634', 'NM_002443']] (106886, 106991) [['NM_138634', 'NM_002443']] (100708, 100742) [['NM_138634', 'NM_002443']] (35055935, 35056061) [['NM_002313', 'NM_001003407', 'NM_001003408']] ''' from pyparsing import * keys = Suppress('(') + Word(nums) + Suppress(',') + Word(nums) + Suppress(')') values = Group(Suppress('[[') + delimitedList(sglQuotedString.setParseAction(removeQuotes)) + Suppress(']]')) expr = keys + values for result, start, end in expr.scanString(data): print '%s %s\t%s' % (result[0], result[1], ','.join(result[2])) Kent _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor