diff options
author | steven.bethard <devnull@localhost> | 2010-02-28 05:25:47 +0000 |
---|---|---|
committer | steven.bethard <devnull@localhost> | 2010-02-28 05:25:47 +0000 |
commit | 0c7f9144b45ea34d3e38090050c3b64e28218f1b (patch) | |
tree | f66189c8664c8dab1d96db3edea428d59b0a39a4 /argparse.py | |
parent | 6f0470065b4aa7c8673ba375b4d99b8809999fb5 (diff) | |
download | argparse-0c7f9144b45ea34d3e38090050c3b64e28218f1b.tar.gz |
Namespace objects now support "in" (__contains__).
Usage and help (but not version) messages are written to stdout, not stderr.
Diffstat (limited to 'argparse.py')
-rw-r--r-- | argparse.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/argparse.py b/argparse.py index 95fdd72..83844d7 100644 --- a/argparse.py +++ b/argparse.py @@ -1178,6 +1178,9 @@ class Namespace(_AttributeHolder): def __ne__(self, other): return not (self == other) + def __contains__(self, key): + return key in self.__dict__ + class _ActionsContainer(object): @@ -2294,9 +2297,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer): # Help-printing methods # ===================== def print_usage(self, file=None): + if file is None: + file = _sys.stdout self._print_message(self.format_usage(), file) def print_help(self, file=None): + if file is None: + file = _sys.stdout self._print_message(self.format_help(), file) def print_version(self, file=None): |