readline() - problem

Wayne Brehaut wbrehaut at mcsnet.ca
Tue Oct 2 17:40:20 EDT 2007


On Tue, 02 Oct 2007 12:13:21 -0000, piotr at kolodziejczyk.waw.pl wrote:

>On 2 Pa , 13:39, Ben Finney <bignose+hates-s... at benfinney.id.au>
>wrote:
>> pi... at kolodziejczyk.waw.pl writes:
>> > import string
>>
>> Why import 'string' if you're not using it?
>>
>> > f=open('/test/test.asc','r')
>> > o=open('/test/out.asc','w')
>> > for line in f:
>> >     s= f.readline()
>>
>> Your line object is already bound to the 'line' name in each
>> iteration. You need to use that, not attempt to read yet another line
>> each time.
>>
>
>Of course, it helped. Many thanks for all.

But be sure you note Wesley's point in teh following post:

If you want the 15th character your subscript must be 14, since
there's a 0th element?

wwwayne

>
>piotr



More information about the Python-list mailing list