[Baypiggies] string to list question
Glen Jarvis
glen at glenjarvis.com
Thu Aug 5 18:33:09 CEST 2010
Although a minor point as the following will work just fine, however, the character class should be [ACGT] instead of [A-Z] as the alphabet for the domain is smaller. (possibly through in a U depending upon the source of the data).
Cheers,
Glen
> Use an re, like so:
>
>>>> import re
>>>> a = "AB/DE"
>>>> [s.group() for s in re.finditer("([A-Z]/[A-Z]|[A-Z])", a)]
> ['A', 'B/D', 'E']
>
>
> 2010/8/5 Brian Rue <brian at lolapps.com>:
>> Naive solution:
>> zlist = [z[0], z[1:4], z[4]]
>>
>> On Wed, Aug 4, 2010 at 9:37 PM, Vikram K <kpguy1975 at gmail.com> wrote:
>>>
>>> Suppose i have this string:
>>> z = 'AT/CG'
>>>
>>> How do i get this list:
>>>
>>> zlist = ['A','T/C','G']
>>>
>>>
>>> _______________________________________________
>>> Baypiggies mailing list
>>> Baypiggies at python.org
>>> To change your subscription options or unsubscribe:
>>> http://mail.python.org/mailman/listinfo/baypiggies
>>
>>
>> _______________________________________________
>> Baypiggies mailing list
>> Baypiggies at python.org
>> To change your subscription options or unsubscribe:
>> http://mail.python.org/mailman/listinfo/baypiggies
>>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> http://mail.python.org/mailman/listinfo/baypiggies
More information about the Baypiggies
mailing list