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
optparse.OptionGroup with_statement context handling #46408
Comments
Adding these four lines to optparse.OptionGroup makes using option def __enter__(self):
return self
def __exit__(self, *exc_info):
self.parser.add_option_group(self) You can then do things like: with OptionGroup(parser, "Group name") as group:
group.add_option(...) |
Patch is inline. |
Is there anything I can do to get this feature request considered |
This API is too "magical" to my liking and doesn't really reflect what group = OptionGroup(parser, "Group name")
group.add_option(...)
parser.add_option_group(group) Finally, the __exit__ handler adds the option group to the parser in any |
I agree with Sebastian that this is not a good use for a context manager. |
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: