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) * (Python committer) | 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) * (Python committer) | 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 | |