AttributeError: 'Namespace' object has no attribute
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)
.
Long story short.
Arguments in object returned from parser.parse_args()
should be accessed via properties rather than via []
syntax.
Wrong
args = parser.parse_args()
args['method']
Correct
args = parser.parse_args()
args.method