Hello,
Thanks both of you for these useful information.
Regards
Karim
Hugo Arts wrote:
On Thu, Mar 18, 2010 at 12:54 PM, Stefan Behnel wrote:
Karim Liateni, 04.03.2010 01:23:
Yes, a *big* difference in the true sense of the word. Your code (assuming
you meant to write "... for line in ..
On Thu, Mar 18, 2010 at 12:54 PM, Stefan Behnel wrote:
> Karim Liateni, 04.03.2010 01:23:
>
> Yes, a *big* difference in the true sense of the word. Your code (assuming
> you meant to write "... for line in ..." ) evaluates the entire list
> comprehension before returning from the call. Steven's c
Karim Liateni, 04.03.2010 01:23:
Steven D'Aprano wrote:
def skip_blanks(lines):
"""Remove leading and trailing whitespace, ignore blank lines."""
for line in lines:
line = line.strip()
if line:
yield line
Is there a big difference to write your first functions as below because
I am not familia
Hello Steven,
Is there a big difference to write your first functions as below because
I am not familiar with yield keyword?
def skip_blanks(lines):
"""Remove leading and trailing whitespace, ignore blank lines."""
return [line.strip() in lines if line.strip()]
I tried to write as wel
On Tue, 2 Mar 2010 05:22:43 pm Andrew Fithian wrote:
> Hi tutor,
>
> I have a large text file that has chunks of data like this:
>
> headerA n1
> line 1
> line 2
> ...
> line n1
> headerB n2
> line 1
> line 2
> ...
> line n2
>
> Where each chunk is a header and the lines that follow it (up to the
>
On Mon, 1 Mar 2010 22:22:43 -0800
Andrew Fithian wrote:
> Hi tutor,
>
> I have a large text file that has chunks of data like this:
>
> headerA n1
> line 1
> line 2
> ...
> line n1
> headerB n2
> line 1
> line 2
> ...
> line n2
>
> Where each chunk is a header and the lines that follow it (up
Andrew Fithian wrote:
Hi tutor,
I have a large text file that has chunks of data like this:
headerA n1
line 1
line 2
...
line n1
headerB n2
line 1
line 2
...
line n2
Where each chunk is a header and the lines that follow it (up to the
next header). A header has the number of lines in the chun
Hi tutor,
I have a large text file that has chunks of data like this:
headerA n1
line 1
line 2
...
line n1
headerB n2
line 1
line 2
...
line n2
Where each chunk is a header and the lines that follow it (up to the next
header). A header has the number of lines in the chunk as its second field.
I