On Jan 24, 4:56 am, 88888 Dihedral <dihedral88...@googlemail.com> wrote: > 在 2012年1月23日星期一UTC+8上午2时01分11秒,Robert Kern写道: > > [line.strip('\n') for line in f] > > This is more powerful by turning an object to be iterable. > But the list comprehension violates the basic operating > principle of the iteratee chaining rule in programming.
Thankfully, the syntax is almost identical for generators, which are chain-able: noEOLs = (line.strip('\n') for line in f) txtSuffix = (line for line in noEOLs if line.endswith('txt')) ...etc > I know manny python programmers just abandon the list comprehension > in non-trivial processes. Really? Observation of the python mailing list indicates the opposite: people seem inclined to use them no matter what. Also: PLEASE STOP DOUBLE POSTING. -- http://mail.python.org/mailman/listinfo/python-list