[New-bugs-announce] [issue2155] optparse.OptionGroup with_statement context handling

Michael Hoffman report at bugs.python.org
Thu Feb 21 16:48:01 CET 2008


New submission from Michael Hoffman:

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(...)

----------
components: Library (Lib)
messages: 62625
nosy: hoffman
severity: normal
status: open
title: optparse.OptionGroup with_statement context handling
type: feature request

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2155>
__________________________________


More information about the New-bugs-announce mailing list