KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I just noticed a behavior in argparse that puzzled me (guess I'd never used it for a dumb list of files before): import argparse parser = argparse.ArgumentParser() parser.add_argument('multi', action='append', nargs='+') print(parser.parse_args()) This gives me the output: ~$ ./testargs.py foo bar baz Namespace(multi=[['foo', 'bar', 'baz']]) ~$ I expected multi to be ['foo', 'bar', 'baz'] , not a list within a list. As-is, I'll have to grab args.multi[0] before processing, which isn't a big deal, but feels like an ugly wart, and I'd like to understand why it's there. Am I doing something silly in add_argument , or is this just an unavoidable quirk?
Tags (comma-separated)
Save Edits
Cancel