Python prob
Darren Teo
darrenteo82 at yahoo.com
Fri May 30 08:38:31 EDT 2003
Hey just wondering y this does not work .. i am tryin to read from a file and it returns a list of all lines from a file except lines with a '#'. The lines returned also must not end with new-line chars. Can any one help?
thanx =)
import string
import sys
true = 1
false = 0
def readlines(filename):
infile = open("test.txt", "r")
while 1:
text = infile.readlines()
if text == "":
break
if text[0] == '#':
continue
if not text:
break
text = text.rstrip()
infile.close()
return text
---------------------------------
Do you Yahoo!?
Free online calendar with sync to Outlook(TM).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20030530/f4fc65e6/attachment.html>
More information about the Python-list
mailing list