Re: [Tutor] Regular expression re.search() object . Please help

2005-01-14 Thread Jeff Shannon
Jacob S. wrote: I assume that both you and Liam are using previous-er versions of python? Now files are iterators by line and you can do this. openFile = open("probe_pairs.txt","r") indexesToRemove = [] for line in openFile: # [...] My version of Python isn't *that* old (IIRC this works since 2

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Liam Clarke
I'm using 2.3, I was trying to be as explicit as possible. *grin* On Thu, 13 Jan 2005 22:02:13 -0500, Jacob S. <[EMAIL PROTECTED]> wrote: > I assume that both you and Liam are using previous-er versions of python? > Now files are iterators by line and you can do this. > > openFile = open("probe_

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Jacob S.
I assume that both you and Liam are using previous-er versions of python? Now files are iterators by line and you can do this. openFile = open("probe_pairs.txt","r") indexesToRemove = [] for line in openFile: if line.startswith("Name="): line = '' ## Ooops, this won't work because it

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Alan Gauld
> I have looked into many books including my favs( > Larning python and Alan Gaulds Learn to program using Yes this is pushing regex a bit further than I show in my book. > What I want to extract: > I want to extract 164:623: > Which always comes after _at: and ends with ; You should be able to

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Alan Gauld
> My list looks like this: List name = probe_pairs > Name=AFFX-BioB-5_at > Cell1=96 369 N control AFFX-BioB-5_at > Cell2=96 370 N control AFFX-BioB-5_at > Cell3=441 3 N control AFFX-BioB-5_at > Cell4=441 4 N control AFFX-BioB-5_at > ... > My Script: > >>> name1 = '[N][a][m][e][=]' Why not just: 'N

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Karl Pflästerer
On 13 Jan 2005, [EMAIL PROTECTED] wrote: > My list looks like this: List name = probe_pairs > Name=AFFX-BioB-5_at > Cell1=96 369 N control AFFX-BioB-5_at > Cell2=96 370 N control AFFX-BioB-5_at > Cell3=441 3 N control AFFX-BioB-5_at > Cell4=441 4

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread jfouhy
Quoting kumar s <[EMAIL PROTECTED]>: > For example: > > I have a simple list like the following: > > >>> seq > ['>probe:HG-U133B:20_s_at:164:623; > Interrogation_Position=6649 ; Antisense;', > 'TCATGGCTGACAACCCATCTTGGGA'] > > > Now I intend to extract particular pattern and write > to anot

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread kumar s
Hello group: thank you for the suggestions. It worked for me using if not line.startswith('Name='): expression. I have been practising regular expression problems. I tumle over one simple thing always. After obtaining either a search object or a match object, I am unable to apply certain metho

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread "Jörg Wölke"
> Quoting Jeff Shannon <[EMAIL PROTECTED]>: [ snip ] > (hmm, I wonder which is the faster option...) Propably "grep -v ^Name= filename" > -- > John. 0.2 EUR, J"o! -- Wir sind jetzt ein Imperium und wir schaffen uns unsere eigene Realität. Wir sind die Akteure der Geschichte, und Ihnen, I

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread jfouhy
Quoting Jeff Shannon <[EMAIL PROTECTED]>: > If the intent is simply to remove all lines that begin with "Name=", > and setting those lines to an empty string is just shorthand for that, > it'd make more sense to do this with a filtering list comprehension: [...] > If one wants to avoid list comp

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Jeff Shannon
Liam Clarke wrote: openFile=file("probe_pairs.txt","r") probe_pairs=openFile.readlines() openFile.close() indexesToRemove=[] for lineIndex in range(len(probe_pairs)): if probe_pairs[lineIndex].startswith("Name="): probe_pairs[lineIndex]='' If the intent is simply to remo

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Liam Clarke
...as do I. openFile=file("probe_pairs.txt","r") probe_pairs=openFile.readlines() openFile.close() indexesToRemove=[] for lineIndex in range(len(probe_pairs)): if probe_pairs[lineIndex].startswith("Name="): indexesToRemove.append(lineIndex) for index in indexesToRe

Re: [Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread Danny Yoo
On Thu, 13 Jan 2005, kumar s wrote: > My list looks like this: List name = probe_pairs > Name=AFFX-BioB-5_at > Cell1=96 369 N control AFFX-BioB-5_at > Cell2=96 370 N control AFFX-BioB-5_at > Cell3=441 3 N control AFFX-BioB-5_at > Cell4=441 4

[Tutor] Regular expression re.search() object . Please help

2005-01-13 Thread kumar s
Dear group: My list looks like this: List name = probe_pairs Name=AFFX-BioB-5_at Cell1=96369 N control AFFX-BioB-5_at Cell2=96370 N control AFFX-BioB-5_at Cell3=441 3 N control AFFX-BioB-5_at Cell4=441 4 N control AFFX-BioB-5_