4 # This should be the new dir(), except that it should still list
5 # the current local name space by default
9 dictkeys
= x
.__dict
__.keys()
10 except (AttributeError, TypeError):
14 methods
= x
.__methods
__
15 except (AttributeError, TypeError):
19 members
= x
.__members
__
20 except (AttributeError, TypeError):
24 the_class
= x
.__class
__
25 except (AttributeError, TypeError):
30 except (AttributeError, TypeError):
33 total
= dictkeys
+ methods
+ members
35 # It's a class instace; add the class's attributes
36 # that are functions (methods)...
37 class_attrs
= listattrs(the_class
)
39 for name
in class_attrs
:
40 if is_function(getattr(the_class
, name
)):
41 class_methods
.append(name
)
42 total
= total
+ class_methods
44 # It's a derived class; add the base class attributes
46 base_attrs
= listattrs(base
)
47 total
= total
+ base_attrs
51 while i
+1 < len(total
):
52 if total
[i
] == total
[i
+1]:
59 # Helper to recognize functions
62 return type(x
) == type(is_function
)
65 # Approximation of builtin dir(); but note that this lists the user's
66 # variables by default, not the current local name space.
73 return listattrs(__main__
)