summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorSkip Montanaro <skip@pobox.com>2004-09-20 15:40:38 (GMT)
committerSkip Montanaro <skip@pobox.com>2004-09-20 15:40:38 (GMT)
commit41f89a4f3dd38d0f09be4586769a1f5b922402c8 (patch)
tree94f863a9ac08ef405b921bede68a305b6c97eda4 /Lib/inspect.py
parent729d47db091f33ab366be2e43d7bee17f06d10d7 (diff)
downloadcpython-41f89a4f3dd38d0f09be4586769a1f5b922402c8.zip
cpython-41f89a4f3dd38d0f09be4586769a1f5b922402c8.tar.gz
cpython-41f89a4f3dd38d0f09be4586769a1f5b922402c8.tar.bz2
Sort classes by fully qualified name. In the common case where you are
displaying a set of classes from one module it doesn't matter, but if you are displaying a large class tree from multiple modules it improves the display to sort by module.name.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 5e3f7e2..101c7ec 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -557,7 +557,8 @@ def getsource(object):
def walktree(classes, children, parent):
"""Recursive helper function for getclasstree()."""
results = []
- classes.sort(key=attrgetter('__name__'))
+ classes.sort(lambda a, b: cmp("%s.%s" % (a.__module__, a.__name__),
+ "%s.%s" % (b.__module__, b.__name__)))
for c in classes:
results.append((c, c.__bases__))
if c in children: