- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
Issue2155
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2008-02-21 15:47 by hoffman, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg62625 - (view) | Author: Michael Hoffman (hoffman) | Date: 2008-02-21 15:47 | |
Adding these four lines to optparse.OptionGroup makes using option
groups vastly easier:
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(...)
|
|||
| msg64125 - (view) | Author: Sean Reifschneider (jafo) * ![]() |
Date: 2008-03-19 23:50 | |
Patch is inline. |
|||
| msg77633 - (view) | Author: Michael Hoffman (hoffman) | Date: 2008-12-11 22:05 | |
Is there anything I can do to get this feature request considered earlier? I can generate a real patch, but I figured that wouldn't necessary for something so simple. This has the advantage that it can probably be cut/pasted into any version of the code. |
|||
| msg77872 - (view) | Author: Sebastian Rittau (srittau) * | Date: 2008-12-15 15:31 | |
This API is too "magical" to my liking and doesn't really reflect what context manager's are supposed to do, i.e. handling resources. Also, I don't see much advantage over: 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 case, whether there was an exception raised inside the block or not. |
|||
| msg112340 - (view) | Author: Georg Brandl (georg.brandl) * ![]() |
Date: 2010-08-01 14:58 | |
I agree with Sebastian that this is not a good use for a context manager. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:31 | admin | set | github: 46408 |
| 2010-08-01 14:58:26 | georg.brandl | set | status: open -> closed nosy: + georg.brandl messages: + msg112340 resolution: rejected |
| 2008-12-15 15:31:01 | srittau | set | nosy:
+ srittau messages: + msg77872 |
| 2008-12-11 22:05:21 | hoffman | set | messages: + msg77633 |
| 2008-03-19 23:50:51 | jafo | set | priority: normal assignee: gward messages: + msg64125 keywords: + patch nosy: + gward, jafo |
| 2008-02-21 15:47:59 | hoffman | create | |


