On Nov 4, 4:30 pm, [EMAIL PROTECTED] wrote: > tmallen: > > > I'm parsing some text files, and I want to strip blank lines in the > > process. Is there a simpler way to do this than what I have here? > > lines = filter(lambda line: len(line.strip()) > 0, lines) > > xlines = (line for line in open(filename) if line.strip()) > > Bye, > bearophile
I must be missing something: >>> xlines = (line for line in open("new.data") if line.strip()) >>> xlines <generator object at 0x6b648> >>> xlines.sort() Traceback (most recent call last): File "<stdin>", line 1, in <module> AttributeError: 'generator' object has no attribute 'sort' What do you think? Thomas -- http://mail.python.org/mailman/listinfo/python-list