[Tutor] list problem

Kent Johnson kent37 at tds.net
Wed Feb 21 14:23:00 CET 2007


> Kirk Bailey wrote:
>> ok, here comes some code:
>>
>> f1=open(pagename,'r')
>> page=f1.readlines()
>> f1.close()
>>
>> at the end of which, the data is in page, which is a list. But 
>> something strange is going on here. all the data is in a single cell! 
>> it's a one cell list! Say what?

It sounds like for some reason the newer Python is not recognizing the 
line endings in the file. I'm not sure why that would be; are you 
running both versions on the same OS? That could cause different 
behaviour since the default line ending is different on Windows and 
Linux, for example.

Try opening the file with universal line endings:
f1 = open(pagename, 'Ur')

Kent

>>
>> Later on, when we try to itenerate the list and do things line by 
>> line, it takes the entire thing at one swallow, and this creates some 
>> trouble.
>>
>> Here's is a link to the entire program.
>> http://www.tinylist.org/MW.txt
>> this is the reader engine for a wiki to be used in a windows environment.



More information about the Tutor mailing list