Python prob
BOCQUET Jean-Francois
jean-francois.bocquet at nospam.eurocontrol.int
Fri May 30 10:16:46 EDT 2003
hello,
you want some help for your house work ? It seems that one of your friend was smarter than you to get help : see the post from "Scott Meyers"
regards
"Darren Teo" <darrenteo82 at yahoo.com> wrote in message news:mailman.1054298446.21505.python-list at python.org...
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/7c5d6e1a/attachment.html>
More information about the Python-list
mailing list