Skip to content

Instantly share code, notes, and snippets.

@funrep
Created November 4, 2012 14:07
Show Gist options
  • Save funrep/4012064 to your computer and use it in GitHub Desktop.
Save funrep/4012064 to your computer and use it in GitHub Desktop.
# 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