Mark Wilkinson wrote:
> Why this:
>
>> lines = iter(infile.readline, "")
>> # copy one line at a time
>> for line in lines:
>
> Rather than this?
>
>> for line in infile:
file.next() uses an internal cache. The data in that cache would be lost
when the rest of the file is copied using file.rea
Why this:
> lines = iter(infile.readline, "")
> # copy one line at a time
> for line in lines:
Rather than this?
> for line in infile:
..Mark
This email and any attachment may contain confidential, privileged information
for the sole use of the intended recipient. If you are not the intended
On 2006-05-16, Peter Otten <[EMAIL PROTECTED]> wrote:
>> Now how can I achieve, what I want? Really exchange one line with
>> another, regardless of their length. Is this possible? If this is not
>> possible, then what would be the best approach to do this?
>
> A file is exposed as a sequence of by
Marco Herrn wrote:
> I have a text file with some lines in it.
> Now I want to iterate over this file and exchange some lines with some
> others. I tried this approach:
> This should inspect the file and find the first line, that can't be
> split into two parts (that means, which has only one wor
Marco Herrn wrote:
> Hi,
>
> I have a text file with some lines in it.
> Now I want to iterate over this file and exchange some lines with some
> others. I tried this approach:
>
> try:
> myfile= file('myfile', 'r+')
>
> while 1:
> line= myfile.readline()
>