diff options
| author | Raymond Hettinger <python@rcn.com> | 2005-02-07 14:16:21 (GMT) | 
|---|---|---|
| committer | Raymond Hettinger <python@rcn.com> | 2005-02-07 14:16:21 (GMT) | 
| commit | f715366f23f47832a4b9914c54d5a63b19f17eba (patch) | |
| tree | ee5f60f4631f6fdad98711dc86ad128724effb11 /Lib/optparse.py | |
| parent | a164574937d6ed32060ad34ea04913ca10741394 (diff) | |
| download | cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.zip cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.tar.gz cpython-f715366f23f47832a4b9914c54d5a63b19f17eba.tar.bz2  | |
Reduce the usage of the types module.
Diffstat (limited to 'Lib/optparse.py')
| -rw-r--r-- | Lib/optparse.py | 11 | 
1 files changed, 5 insertions, 6 deletions
diff --git a/Lib/optparse.py b/Lib/optparse.py index 6d3c94b..ae3d00d 100644 --- a/Lib/optparse.py +++ b/Lib/optparse.py @@ -67,7 +67,6 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  """  import sys, os -import types  import textwrap  try:      from gettext import gettext as _ @@ -590,7 +589,7 @@ class Option:              if self.choices is None:                  raise OptionError(                      "must supply a list of choices for type 'choice'", self) -            elif type(self.choices) not in (types.TupleType, types.ListType): +            elif type(self.choices) not in (tuple, list):                  raise OptionError(                      "choices must be a list of strings ('%s' supplied)"                      % str(type(self.choices)).split("'")[1], self) @@ -634,12 +633,12 @@ class Option:                  raise OptionError(                      "callback not callable: %r" % self.callback, self)              if (self.callback_args is not None and -                type(self.callback_args) is not types.TupleType): +                type(self.callback_args) is not tuple):                  raise OptionError(                      "callback_args, if supplied, must be a tuple: not %r"                      % self.callback_args, self)              if (self.callback_kwargs is not None and -                type(self.callback_kwargs) is not types.DictType): +                type(self.callback_kwargs) is not dict):                  raise OptionError(                      "callback_kwargs, if supplied, must be a dict: not %r"                      % self.callback_kwargs, self) @@ -927,7 +926,7 @@ class OptionContainer:          """add_option(Option)             add_option(opt_str, ..., kwarg=val, ...)          """ -        if type(args[0]) is types.StringType: +        if type(args[0]) is str:              option = self.option_class(*args, **kwargs)          elif len(args) == 1 and not kwargs:              option = args[0] @@ -1213,7 +1212,7 @@ class OptionParser (OptionContainer):      def add_option_group(self, *args, **kwargs):          # XXX lots of overlap with OptionContainer.add_option() -        if type(args[0]) is types.StringType: +        if type(args[0]) is str:              group = OptionGroup(self, *args, **kwargs)          elif len(args) == 1 and not kwargs:              group = args[0]  | 
