Commit 3375fc5a authored by Raymond Hettinger's avatar Raymond Hettinger

Apply extract functions instead of lambda.

parent 0ad142ab
...@@ -29,6 +29,7 @@ __author__ = 'Ka-Ping Yee <ping@lfw.org>' ...@@ -29,6 +29,7 @@ __author__ = 'Ka-Ping Yee <ping@lfw.org>'
__date__ = '1 Jan 2001' __date__ = '1 Jan 2001'
import sys, os, types, string, re, dis, imp, tokenize, linecache import sys, os, types, string, re, dis, imp, tokenize, linecache
from operator import attrgetter
# ----------------------------------------------------------- type-checking # ----------------------------------------------------------- type-checking
def ismodule(object): def ismodule(object):
...@@ -553,7 +554,7 @@ def getsource(object): ...@@ -553,7 +554,7 @@ def getsource(object):
def walktree(classes, children, parent): def walktree(classes, children, parent):
"""Recursive helper function for getclasstree().""" """Recursive helper function for getclasstree()."""
results = [] results = []
classes.sort(key=lambda c: c.__name__) classes.sort(key=attrgetter('__name__'))
for c in classes: for c in classes:
results.append((c, c.__bases__)) results.append((c, c.__bases__))
if c in children: if c in children:
......
...@@ -43,6 +43,7 @@ import sys ...@@ -43,6 +43,7 @@ import sys
import imp import imp
import tokenize # Python tokenizer import tokenize # Python tokenizer
from token import NAME, DEDENT, NEWLINE from token import NAME, DEDENT, NEWLINE
from operator import itemgetter
__all__ = ["readmodule", "readmodule_ex", "Class", "Function"] __all__ = ["readmodule", "readmodule_ex", "Class", "Function"]
...@@ -326,8 +327,7 @@ def _main(): ...@@ -326,8 +327,7 @@ def _main():
for obj in objs: for obj in objs:
if isinstance(obj, Class): if isinstance(obj, Class):
print "class", obj.name, obj.super, obj.lineno print "class", obj.name, obj.super, obj.lineno
methods = obj.methods.items() methods = list.sorted(obj.methods.iteritems(), key=itemgetter(1))
methods.sort(lambda a, b: cmp(a[1], b[1]))
for name, lineno in methods: for name, lineno in methods:
if name != "__path__": if name != "__path__":
print " def", name, lineno print " def", name, lineno
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment