This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author barry
Recipients barry
Date 2012-09-10.16:35:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Run the following code snippet:

-----snip snip-----
import argparse

parser = argparse.ArgumentParser()
parser.add_argument("--test", dest="test", type=str,
    default=[], action='append')

args = parser.parse_args()

print args.test, repr(args.test)
-----snip snip-----

In Python 3.3 (with the appropriate syntactic changes), args.test is clearly a list.  In Python 2.7 and 3.2, args.test is the string "[]".  I can't tell from reading the docs what the expected value should be, but intuitively, the Python 3.3 behavior makes the most sense, i.e. that args.test is a list, not the string representation of a list!

Removing type=str from add_argument() "fixes" the value, but that doesn't seem right because str is the default type so that should have no effect.

We discovered this when we tried to do args.test.append('foo') and tracebacked because args.test wasn't a list.

Original bug report in Ubuntu:
but I've tested this with upstream hg head for 2.7, 3.2, and 3.3.  It works in Ubuntu's 3.3rc2 but not in upstream head 3.3rc2+, so from reading Misc/NEWS I think the fix for issue #12776 and issue #11839 might be involved.
Date User Action Args
2012-09-10 16:35:13barrysetrecipients: + barry
2012-09-10 16:35:12barrysetmessageid: <>
2012-09-10 16:35:12barrylinkissue15906 messages
2012-09-10 16:35:12barrycreate