Hacker News new | ask | show | jobs
by hiccuphippo 815 days ago
Python comes with a built-in module called fileinput that makes this very easy. It checks sys.argv[1] and reads from it or from stdin if it's empty or a dash.

https://docs.python.org/3/library/fileinput.html