New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding __iter__ to class Values of module optparse #46696
Comments
Hi, Doing (opts, args) = parser.parse_args(), supposing parser is an This patch adds the __iter__ method to the class Values so it is Right now it is possible to do this but you would have to iterate over |
I'd like this. I had one instance where a number of options where |
This seems to be a reasonable request. |
Why can't you just iterate over |
I consider iterating over opts to be nicer and more pythonic than using |
But Anyway, I should point out that optparse is maintained separately from |
There is another reason for considering __iter__ as a more pythonic About optparse being maintained separately.. isn't there someone |
My experience in the past has been that the optik/optparse maintainer |
gpolo: The argument still doesn't hold. As you point out, it's the The question then is one for optik. Why doesn't values simply inherit >>> (opts, args) = parser.parse_args(values={})
>>> print opts
{}
>>> |
I have asked that myself, shawnmore. Why not let Value subclass dict ? |
Subclassing dict seems like a bad idea. The options value returned by |
Given the disagreement found here, I suggest closing this rfe and moving |
Closing on OP's request. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: