[issue15906] argparse add_argument() confusing behavior when type=str, default=

Chris Jerdonek report at bugs.python.org
Tue Sep 11 19:14:50 CEST 2012


Chris Jerdonek added the comment:

Here is a type of test case that I think should be considered for addition (to confirm that the code doesn't double-convert strings in at least one case).  Maybe there is already a test case like this:

class MyString(str): pass

def convert(s):
    return MyString("*" + s)

parser = ArgumentParser()
parser.add_argument("--test", dest="test", type=convert, default="foo")
args = parser.parse_args()

print(args.test)

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue15906>
_______________________________________


More information about the Python-bugs-list mailing list