diff options
author | Guido van Rossum <guido@python.org> | 1991-12-26 13:04:02 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1991-12-26 13:04:02 (GMT) |
commit | 946749f6fe31c07433cb58bf82803fa8e2acdd38 (patch) | |
tree | dd4d80a1ddb87d03b0636a340dfd509c3fdd9923 /Lib/newdir.py | |
parent | 2234bc91013622812dee0a5a58475170d89c512d (diff) | |
download | cpython-946749f6fe31c07433cb58bf82803fa8e2acdd38.zip cpython-946749f6fe31c07433cb58bf82803fa8e2acdd38.tar.gz cpython-946749f6fe31c07433cb58bf82803fa8e2acdd38.tar.bz2 |
Use AttributeError
Diffstat (limited to 'Lib/newdir.py')
-rw-r--r-- | Lib/newdir.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/newdir.py b/Lib/newdir.py index 7164b98..9d07d6c 100644 --- a/Lib/newdir.py +++ b/Lib/newdir.py @@ -11,27 +11,27 @@ def getattr(x, name): def listattrs(x): try: dictkeys = x.__dict__.keys() - except (NameError, TypeError): + except (AttributeError, TypeError): dictkeys = [] # try: methods = x.__methods__ - except (NameError, TypeError): + except (AttributeError, TypeError): methods = [] # try: members = x.__members__ - except (NameError, TypeError): + except (AttributeError, TypeError): members = [] # try: the_class = x.__class__ - except (NameError, TypeError): + except (AttributeError, TypeError): the_class = None # try: bases = x.__bases__ - except (NameError, TypeError): + except (AttributeError, TypeError): bases = () # total = dictkeys + methods + members @@ -69,7 +69,7 @@ def is_function(x): # Use a class method to make a function that can be called # with or without arguments. # -class _dirclass(): +class _dirclass: def dir(args): if type(args) = type(()): return listattrs(args[1]) |