Python-2.5.1/Objects/object.c:PyObject_Dir を Python に変換するとこんな感じ↓
import sys from types import * def dir(object=object()): """This is an implementation of __builtins__.dir in pure Python.""" result = getattr(object, '__dict__', dict()) if object is dir.func_defaults[0]: frame = sys._getframe(1) result = frame.f_locals elif isinstance(object, ModuleType): pass elif isinstance(object, (TypeType, ClassType, )): result = set(result) for base in object.__bases__: result.update(dir(base)) else: result = set(result) # backward compatibility ? result.update(getattr(object, '__members__', ())) result.update(getattr(object, '__methods__', ())) if hasattr(object, '__class__'): result.update(dir(object.__class__)) result = list(result) result.sort() return result
C で書こうが Python で書こうがどうにでもなるのが Pythonic なところか。