Jp Calderone wrote:
On Sun, 27 Mar 2005 14:39:06 -0800, James Stroud <[EMAIL PROTECTED]> wrote:
"ATT/GATA/G"
gets split to
[['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']]
I have written a very ugly function to do this (listed below for the curious), but intuitively I think this should only take a couple of lines for one skilled in regex and/or listcomp. Any takers?
>>> import re
>>> s = 'ATT/GATA/G'
>>> re.findall('(./.|.)', s)
['A', 'T', 'T/G', 'A', 'T', 'A/G']
>>> If it is really important to have ['A'] instead of 'A', etc, looping over the result and noticing strings of length 3 vs length 1, then applying the appropriate transformation, should be simple enough.

>>> [x.split('/') for x in ['A', 'T', 'T/G', 'A', 'T', 'A/G']] [['A'], ['T'], ['T', 'G'], ['A'], ['T'], ['A', 'G']] >>>

/m

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to