enhanced dir? · Issue #91410 · python/cpython (original) (raw)
current dir gives output like this,
from collection import OrderedDict
od = OrderedDict({'a': 1, 'b': 2, 'c': 3})
print(dir(od))
['__class__', '__contains__', '__delattr__', '__delitem__', '__dict__',
'__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__',
'__getitem__', '__gt__', '__hash__', '__init__', '__init_subclass__',
'__iter__', '__le__', '__len__', '__lt__', '__ne__', '__new__', '__reduce__',
'__reduce_ex__', '__repr__', '__reversed__', '__setattr__', '__setitem__',
'__sizeof__', '__str__', '__subclasshook__', 'clear', 'copy', 'fromkeys',
'get', 'items', 'keys', 'move_to_end', 'pop', 'popitem', 'setdefault',
'update', 'values']
but wouldn't it be better if the output was like this,
{'OrderedDict': {'__contains__', '__delitem__', '__dir__', '__eq__',
'__format__', '__ge__', '__getitem__', '__gt__', '__init__', '__init_subclass__',
'__iter__', '__le__', '__lt__', '__ne__', '__reduce__', '__reduce_ex__',
'__repr__', '__reversed__', '__setitem__', '__sizeof__', '__subclasshook__',
'clear', 'copy', 'fromkeys', 'get', 'items', 'keys', 'move_to_end', 'pop',
'popitem', 'setdefault', 'update', 'values'},
'dict': {'__getattribute__', '__len__', '__new__'},
'object': {'__delattr__', '__setattr__', '__str__'}}
???