Message 322142 - Python tracker

Message322142

Author porton
Recipients porton
Date 2018-07-22.12:53:49
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1532264030.24.0.56676864532.issue34188@psf.upfronthosting.co.za>
In-reply-to
Content
The below code produces "rock", but it should produce "a". This (to use dict value instead of the key by argparse result) is both to be a new useful feature (for example to map strings in a command line to certain functions or classes provided as dict values) and conform to intuition better.

My feature proposal breaks backward compatibility, but I think no reasonable programmer wrote it in such a way that he relied on the current behavior for `dict` values for `choices`.

import argparse

parser = argparse.ArgumentParser(prog='game.py')
parser.add_argument('move', choices={'rock':'a', 'paper':'b', 'scissors':'c'})
print(parser.parse_args(['rock']))
History
Date User Action Args
2018-07-22 12:53:50portonsetrecipients: + porton
2018-07-22 12:53:50portonsetmessageid: <1532264030.24.0.56676864532.issue34188@psf.upfronthosting.co.za>
2018-07-22 12:53:50portonlinkissue34188 messages
2018-07-22 12:53:49portoncreate