a break for comprehensions
Cliff Crawford
cjc26 at nospam.cornell.edu
Thu Aug 9 00:06:03 EDT 2001
* Cliff Crawford <cjc26 at nospam.cornell.edu> menulis:
|
| Then you can do stuff like the following, which simulates the Unix 'cat'
| command (warning: untested):
|
| files = reduce(lambda x, y: x+y, GenList(iter(open(sys.argv[1:]))))
Ooops, that should be
files = reduce(lambda x, y: x+y,
[GenList(iter(open(filename))) for filename in sys.argv[1:]])
| for line in files:
| print line,
|
|
--
Cliff Crawford http://www.sowrong.org/
"Today's Goths, who generally tend to be in their teens and 20s,
have nothing to do with the Germanic Visigoths of Europe in the
third and fourth centuries A.D." -- Jimmy Stewart
More information about the Python-list
mailing list