On Fri, Jan 05, 2001 at 04:01:53PM -0600, Ka-Ping Yee wrote: > while (<>) { > ... > } > is simple, quickly learned, frequently used, and instantly recognizable. > import sys > if len(sys.argv) > 1: > file = open(sys.argv[1]) > else: > file = sys.stdin > while 1: > line = file.readline() > if not line: > break > ... ... Except that it can take more than one filename, and will do the one after another, and that it takes "-" as a filename for stdin. Doing it in a script is not dead simple, unless you open up all files at once (which can be harmful, and Perl, for one, doesn't do) or you do most of the work fileinput does. That is why I use fileinput (and while-diamond) -- I might not need it now, but when I do need it, it already works :) -- Thomas Wouters <thomas@xs4all.net> Hi! I'm a .signature virus! copy me into your .signature file to help me spread!
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4