Created
November 4, 2012 14:07
-
-
Save funrep/4012064 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# cat.py | |
import argparse | |
parser = argparse.ArgumentParser(prog='cat.py') | |
parser.add_argument('file', nargs='+', help='file(s) to print and catenate') | |
def main(): | |
args = parser.parse_args() | |
files = open(args.file, 'r').read() | |
print files | |
if __name__ == '__main__': | |
main() | |
# i get this error: | |
# $ ./cat.py file | |
# Traceback (most recent call last): | |
# File "./cat.py", line 20, in <module> | |
# main() | |
# File "./cat.py", line 16, in main | |
# files = open(args.file, 'r').read() | |
# TypeError: coercing to Unicode: need string or buffer, list found |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment