From: Greg Ward Date: Tue, 23 May 2000 01:44:20 +0000 (+0000) Subject: OptionDummy now has a constructor that takes a list of options: each string X-Git-Tag: v2.0b1~1703 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=3c67b1dd08b80a6052d4c097ca5d1b399f0dd941;p=thirdparty%2FPython%2Fcpython.git OptionDummy now has a constructor that takes a list of options: each string in the option list is an attribute of the OptionDummy that will be initialized to None. --- diff --git a/Lib/distutils/fancy_getopt.py b/Lib/distutils/fancy_getopt.py index 39450e807918..588c6ba73fd5 100644 --- a/Lib/distutils/fancy_getopt.py +++ b/Lib/distutils/fancy_getopt.py @@ -239,7 +239,7 @@ class FancyGetopt: if args is None: args = sys.argv[1:] if object is None: - object = OptionDummy() + object = OptionDummy(self.attr_name.values()) created_object = 1 else: created_object = 0 @@ -465,7 +465,14 @@ def wrap_text (text, width): class OptionDummy: """Dummy class just used as a place to hold command-line option values as instance attributes.""" - pass + + def __init__ (self, options=[]): + """Create a new OptionDummy instance. The attributes listed in + 'options' will be initialized to None.""" + for opt in options: + setattr(self, opt, None) + +# class OptionDummy if __name__ == "__main__":