I am writing a program that uses urllib2 to download CSV data from an http site. The program works fine when run within Python, however I am also trying to use
Long story short.
Arguments in object returned from parser.parse_args() should be accessed via properties rather than via [] syntax.
args = parser.parse_args()
args['method']
args = parser.parse_args()
args.method
I had this problem due to a whitespace before the option sting.
You're parsing command line arguments into args, which is a Namespace with attributes set to the parsed arguments. But you're passing this entire namespace to downloadData, rather than just the url. This namespace is then passed to urlopen, which doesn't know what to do with it. Instead, call downloadData(args.url).