Re: [Tutor] Parsing Question

2009-05-10 Thread Stefan Behnel
Emile van Sebille wrote: > On 5/9/2009 5:30 PM Alan Gauld said... > >> You should probably be able to do the first for loop as a list >> comprehension, but I can't think of how to get the split() call >> embedded into it right now! >> > > Just for fun -- given datafile contents... > > 1 one 2 t

Re: [Tutor] Parsing Question

2009-05-10 Thread Emile van Sebille
On 5/9/2009 5:30 PM Alan Gauld said... You should probably be able to do the first for loop as a list comprehension, but I can't think of how to get the split() call embedded into it right now! Just for fun -- given datafile contents... 1 one 2 two 3 three 4 four 5 five 6 six 7 seven 8 eigh

Re: [Tutor] Parsing Question

2009-05-09 Thread Alan Gauld
"Michael Morrissey" wrote a text file that looks like this: 1 the 126 name 2 of 127 very Each has 2 numbers and 2 words on it. Each number is related to the word that comes after it. So "1" and "the" are connected (kinda like a dictionary), and "126" and "name" are related. Using the above t

Re: [Tutor] Parsing Question

2009-05-09 Thread Emile van Sebille
On 5/9/2009 4:23 PM Michael Morrissey said... Forgive me if I'm asking something stupid, but I'm not sure how to do this (there are so many options in Python, I'm overwhelmed and confused). Look into the split method of string objects (which are what you should be reading from the file), the

[Tutor] Parsing Question

2009-05-09 Thread Michael Morrissey
Forgive me if I'm asking something stupid, but I'm not sure how to do this (there are so many options in Python, I'm overwhelmed and confused). I have a text file that looks like this: 1 the 126 name 2 of 127 very 3 to 128 through 4 and 129 just 5 a 130 form 6 in 131 much 7 is 132 great etc... Eac