Would this work for you?

a = ['Name = stuff','CGTATAGCTAGCTA','Name = stuff','CGATATGCCGGCTA']
for index,thing in enumerate(a):
    if "Name=" in thing:
        del a[index]

I know, that it might be slow, but I thought that maybe it would hold its
own because it doesn't have to import the re module, everything's builtin,
etc.

HTH,
Jacob

 Hello group,
>  Thank you very much for your kind replies. In fact I
> survived to pull out what I needed by going with
> Kent's tip by enumerating on iterator.
>
> The problem with me is suddenly I embarked on
> something big problem and I am surviving it in pieces
> by writing pieces of code.
>
>
> I have another question:
> To be brief:
>
> My list contains some elements that I do not want and
> I want to remove unwanted elements in my list:
>
> My TEXT file looks like this:
>
> Name=32972_at
> Cell1=xxx xxx N control 32972_at
> Cell1=xxx xxx N control 32972_at
> Cell1=xxx xxx N control 32972_at
> Cell1=xxx xxx N control 32972_at
> Name=3456_at
> Cell1=xxx xxx N control 3456_at
> Cell1=xxx xxx N control 3456_at
> Cell1=xxx xxx N control 3456_at
> Cell1=xxx xxx N control 3456_at
> .........       ...     x       xxxxxxxxxxxxxxx
> (34K lines)
>
> I want to remove Name=Xxxx_at identifiers.
>
>
> My List:
> ['Name=32972_at',
>
'Cell1=432\t118\tN\tcontrol\t32972_at\t0\t13\tA\tA\tA\t0\t75952\t-1\t-1\t99\
t',
>
'Cell2=432\t117\tN\tcontrol\t32972_at\t0\t13\tA\tT\tA\t0\t75312\t-1\t-1\t99\
t',
>
'Cell3=499\t632\tN\tcontrol\t32972_at\t1\t13\tC\tC\tC\t1\t404979\t-1\t-1\t99
\t']
>
>
> I tried to resolve in this way:
>
> >>>pat = re.compile('Name')
> >>> for i in range(len(cord)):
> x = pat.search(cord[i])
> cord.remove(x)
>
> I know I am wrong here because I do not know how to
> search and remove an element in a list. Can any one
> please help me.
>
> on Page 98, chapter Lists and dictionaries of mark
> lutz's learning python. It is mentioned in table 6-1 :
> L2.append(4)  Methods: grow,sort,search,reverse etc.
>
>
> Although not much is covered on this aspect in this
> book, I failed to do more operations on list.
>
> Looking forward for help from tutors.
>
> Thank you.
> Kumar.
>
>
>
>
>
>
> --- Kent Johnson <[EMAIL PROTECTED]> wrote:
>
> > kumar,
> >
> > Looking at the quantity and structure of your data I
> > think the search you are doing is going to be
> > pretty slow - you will be doing 4504 * 398169 =
> > 1,793,353,176 string searches.
> >
> > Where does the seq data come from? Could you
> > consolidate the pairs of lines into a single record?
> > If
> > you do that and extract the '399:559' portion, you
> > could build a dict that maps '399:559' to the
> > full record. Looking up '399:559' in the dictionary
> > would be much, much faster than searching the
> > entire list.
> >
> > If you have multiple entries for '399:559' you could
> > have the dict map to a list.
> >
> > Kent
> >
> > kumar s wrote:
> > >
> > >>>>len(x)
> > >
> > > 4504
> > >
> > >>>>x[1:10]
> > >
> > > ['454:494', '319:607', '319:608', '322:289',
> > > '322:290', '183:330', '183:329', '364:95',
> > '364:96']
> > >
> > >>>>len(seq)
> > >
> > > 398169
> > >
> > >>>>seq[0:4]
> > >
> > > ['>probe:HG-U95Av2:1000_at:399:559;
> > > Interrogation_Position=1367; Antisense;',
> > > 'TCTCCTTTGCTGAGGCCTCCAGCTT',
> > > '>probe:HG-U95Av2:1000_at:544:185;
> > > Interrogation_Position=1379; Antisense;',
> > > 'AGGCCTCCAGCTTCAGGCAGGCCAA']
> > >
> > >
> > >
> > >>>>for ele1 in x:
> > >
> > > for ele2 in seq:
> > > if ele1 in ele2:
> > > print ele2
> > >
> > >
> > >
> > >>probe:HG-U95Av2:31358_at:454:493;
> > >
> > > Interrogation_Position=132; Antisense;
> > >
> > >>probe:HG-U95Av2:31358_at:319:607;
> > >
> > > Interrogation_Position=144; Antisense;
> > >
> > >
> > >
> > >
> > >
> > >
> > > How Do I WANT:
> > >
> > > I want to print get an output like this:
> > >
> > >
> > >
> > >>probe:HG-U95Av2:1000_at:399:559;
> > >
> > > Interrogation_Position=1367; Antisense;'
> > > TCTCCTTTGCTGAGGCCTCCAGCTT
> > >
> > >
> > >>probe:HG-U95Av2:1000_at:544:185;
> > >
> > > Interrogation_Position=1379; Antisense;
> > > AGGCCTCCAGCTTCAGGCAGGCCAA
> > >
> > >
> > > can any one please suggest what is going wrong in
> > my
> > > statements and how can I get it.
> > >
> > > Thank you.
> > > Kumar
> > >
> > >
> > >
> > > __________________________________
> > > Do you Yahoo!?
> > > Yahoo! Mail - 250MB free storage. Do more. Manage
> > less.
> > > http://info.mail.yahoo.com/mail_250
> > > _______________________________________________
> > > Tutor maillist  -  [EMAIL PROTECTED]
> > > http://mail.python.org/mailman/listinfo/tutor
> > >
> > _______________________________________________
> > Tutor maillist  -  [EMAIL PROTECTED]
> > http://mail.python.org/mailman/listinfo/tutor
> >
>
>
>
>
> __________________________________
> Do you Yahoo!?
> Yahoo! Mail - now with 250MB free storage. Learn more.
> http://info.mail.yahoo.com/mail_250
> _______________________________________________
> Tutor maillist  -  [EMAIL PROTECTED]
> http://mail.python.org/mailman/listinfo/tutor
>
>

_______________________________________________
Tutor maillist  -  [EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/tutor

Reply via email to