On 28 Mar 2005 04:12:15 -0800, [EMAIL PROTECTED]
<[EMAIL PROTECTED]> wrote:
> This is shorter:
> map(list,' '.join(s).replace(' / ','').split())
> 
> but for very long genomes Michael Spencer's nice version can be faster.
> 

for very long genomes he might want a generator:

def xgen(s):
    l = len(s) - 1
    e = enumerate(s)
    for i,c in e:
        if i < l and s[i+1] == '/':
            e.next()
            i2, c2 = e.next()
            yield [c, c2]
        else:
            yield [c]

>>> for g in xgen('ATT/GATA/G'): print g
...
['A']
['T']
['T', 'G']
['A']
['T']
['A', 'G']

Peace
Bill Mill
bill.mill at gmail.com
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to