[issue2155] optparse.OptionGroup with_statement context handling

Sebastian Rittau report at bugs.python.org
Mon Dec 15 16:31:02 CET 2008


Sebastian Rittau <srittau at jroger.in-berlin.de> added the comment:

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.

----------
nosy: +srittau

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue2155>
_______________________________________


More information about the Python-bugs-list mailing list