"tee chwee liong" <[email protected]> wrote
i got syntax error when running this line:
data = for line in open(filename) if not line.startswith("#")
Should be:
data = [ line for line in open(filename) if not line.startswith("#") ]
Notice the extra line at the beginning and the fact that it is
surrounded by [] which makes it a *list comprehension*.
But that won't help if you can't put commment markers
at the front... But you might get away with:
data = [ line for line in open(filename) if '-1' in line ]
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor