Issue4278
Created on 2008-11-07 13:13 by kbriggs, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (4) | |||
|---|---|---|---|
| msg75602 - (view) | Author: Keith Briggs (kbriggs) | Date: 2008-11-07 13:13 | |
I got the message:
optparse.OptionError: invalid long option string '-T0': must start with
--, followed by non-dash
This is bad - the real error was that I gave a short option which did
not have a single letter.
Also, it seems that add_option('--height-of-plot','-h') is not allowed,
because -h can only go with --help. How do I override this?
Keith
|
|||
| msg77499 - (view) | Author: Martin v. Löwis (loewis) * ![]() |
Date: 2008-12-10 08:35 | |
No patch proposed yet, so retargetting to trunk. |
|||
| msg82753 - (view) | Author: Andy Buckley (andybuckley) | Date: 2009-02-26 13:42 | |
Are these really bugs? The first message just reports the error the other way around from how you view it: you are thinking of "-TO" as a two-character "short option", optparse thinks of it as a two-character long option which is missing a dash. I would side with optparse's definition, since the point of short options is that they can be combined under a single dash --- a multi-character option can't do that, and so can't be "short" by definition. In both this and the "-h" issue, optparse is reasonably enforcing a UI convention as well as providing parsing facilities. That uniformity of UI behaviour is a design goal is made explicit in the documentation. Using optparse means that users can rely on "-h" to give them help documentation, which IMO is a very useful convention to respect. And the splitting of long and short options by whether they are single character (and hence can be combined) or multi-character (hence uncombinable, but good for less-used options without eating up the alphabetic option namespace) is another nice convention which optparse enforces. -1 from me: I think the existing behaviours are good, largely *because* they aren't flexible. |
|||
| msg89990 - (view) | Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * ![]() |
Date: 2009-07-01 16:53 | |
- For the -h option, you may add "add_help_option=False" when creating the Optparse object - concerning the error message: every parser that tries to give meaningful error messages has to guess what the user really meant. The exact text is really an implementation detail. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:41 | admin | set | github: 48528 |
| 2009-07-01 16:53:00 | amaury.forgeotdarc | set | status: open -> closed nosy:
+ amaury.forgeotdarc resolution: works for me |
| 2009-02-26 13:42:03 | andybuckley | set | nosy:
+ andybuckley messages: + msg82753 |
| 2008-12-10 08:35:53 | loewis | set | nosy:
+ loewis messages: + msg77499 versions: + Python 2.7, - Python 2.5.3 |
| 2008-11-07 13:13:39 | kbriggs | create | |
