Re:Show HN: A simple Unix cat implementation in various lang...
by rspivak on Saturday February 29, 2020 @07:49PM
(#22454329)
Feel free to add your own implementation. :)
[ Parent
| on HN ]
Re:Show HN: A simple Unix cat implementation in various lang...
by eesmith on Sunday March 01, 2020 @12:39AM
(#22455324)
FWIW, iter() handles the logic of testing for an explicit EOF marker, so another way to write it is:
import sys
with open(sys.argv[1]) as fin:
for c in iter((lambda: fin.read(1)), ""):
sys.stdout.write(c)