Created
January 10, 2015 21:13
-
-
Save Squab/d4190acdcacb56c918dc to your computer and use it in GitHub Desktop.
Make a Python script behave like a Linux command (take a filename or stdin)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
if __name__ == "__main__": | |
f = None | |
try: | |
filename = sys.argv[1] | |
f = open(filename, 'r') | |
except IndexError: | |
f = sys.stdin.readlines() | |
for line in f: | |
print line, |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment