Message322142
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'])) |
|
| Date |
User |
Action |
Args |
| 2018-07-22 12:53:50 | porton | set | recipients:
+ porton |
| 2018-07-22 12:53:50 | porton | set | messageid: <1532264030.24.0.56676864532.issue34188@psf.upfronthosting.co.za> |
| 2018-07-22 12:53:50 | porton | link | issue34188 messages |
| 2018-07-22 12:53:49 | porton | create | |
|