Message80704
| Author |
pycurry |
| Recipients |
pycurry |
| Date |
2009年01月28日.10:58:24 |
| SpamBayes Score |
2.3865955e-08 |
| Marked as misclassified |
No |
| Message-id |
<1233140307.53.0.685208172708.issue5088@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
Although it is possible to specify a default value for an append action,
either directly or through the set_default() function, it is not handled
correctly when this default is overruled by the user. Take for example
the following code:
import optparse
parser = optparse.OptionParser()
parser.add_option("-o", "--option", action = "append")
parser.set_defaults(option = ["a"])
options, args = parser.parse_args()
print options
When this is called without arguments the following is printed:
{'option': ['a']} # as expected
But when it is called with for example with -ob the following is
printed:
{'option': ['a', 'b']} # expected {'option': ['b']}
So the default option is also appended, even if the option is explicitly defined by the user. |
|
History
|
|---|
| Date |
User |
Action |
Args |
| 2009年01月28日 10:58:27 | pycurry | set | recipients:
+ pycurry |
| 2009年01月28日 10:58:27 | pycurry | set | messageid: <1233140307.53.0.685208172708.issue5088@psf.upfronthosting.co.za> |
| 2009年01月28日 10:58:25 | pycurry | link | issue5088 messages |
| 2009年01月28日 10:58:24 | pycurry | create |
|