Message111279
Note that the negative number heuristic you're complaining about doesn't actually affect your code below. The negative number heuristic is only used when you have some options that look like negative numbers. See the docs for more information:
http://docs.python.org/library/argparse.html#arguments-containing
Your problem is that you want "--safe" to be treated as a positional argument even though you've declared it as an option. Basically there are two reasonable interpretations of this situation. Consider something like "--conf-file --safe". Either the user wants a conf file named "--safe", or the user accidentally forgot to type the name of the conf file. Argparse assumes the latter, though either one is conceivable. Argparse assumes the latter because, while it occasionally throws an unnecessary exception, the other behavior would allow an error to pass silently.
I'm definitely opposed to changing the default behavior to swallow some errors silently. If you'd like to propose an API for enabling such behavior explicitly and supply a patch and tests implementing it, I'll be happy to review it though. |
|
Date |
User |
Action |
Args |
2010-07-23 11:21:14 | bethard | set | recipients:
+ bethard, eric.smith, r.david.murray, andersk, gdb, nelhage |
2010-07-23 11:21:14 | bethard | set | messageid: <1279884074.33.0.439403235075.issue9334@psf.upfronthosting.co.za> |
2010-07-23 11:21:12 | bethard | link | issue9334 messages |
2010-07-23 11:21:12 | bethard | create | |
|