summaryrefslogtreecommitdiff
path: root/fancy_getopt.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2000-05-23 01:44:20 +0000
committerGreg Ward <gward@python.net>2000-05-23 01:44:20 +0000
commit138ae247bb47e34672d909a46fa998a4b86b90f6 (patch)
tree7cb5b8f3a764690e399120aac15b9505a07aa5e7 /fancy_getopt.py
parent1ea22ad71cc61f4f7467262c768ec43fabbb81d2 (diff)
downloadpython-setuptools-git-138ae247bb47e34672d909a46fa998a4b86b90f6.tar.gz
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.
Diffstat (limited to 'fancy_getopt.py')
-rw-r--r--fancy_getopt.py11
1 files changed, 9 insertions, 2 deletions
diff --git a/fancy_getopt.py b/fancy_getopt.py
index 39450e80..588c6ba7 100644
--- a/fancy_getopt.py
+++ b/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__":