[issue47254] enhanced dir?

apostofes report at bugs.python.org
Thu Apr 7 21:33:59 EDT 2022


apostofes <aivainjr141 at gmail.com> added the comment:

plus I would want it to have some more methods,
```
l = [1, 2, 3]
```
using enhanced dir should give,
```
{'list': {'__add__', '__contains__', '__delitem__', '__eq__', '__ge__',
         '__getattribute__', '__getitem__', '__gt__', '__iadd__', '__imul__',
         '__init__', '__init_subclass__', '__iter__', '__le__', '__len__',
         '__lt__', '__mul__', '__ne__', '__new__', '__repr__',
         '__reversed__', '__rmul__', '__setitem__', '__sizeof__',
         '__subclasshook__', 'append', 'clear', 'copy', 'count', 'extend',
         'index', 'insert', 'pop', 'remove', 'reverse', 'sort'},
'object': {'__delattr__', '__dir__', '__format__', '__reduce__', '__reduce_ex__', '__setattr__', '__str__'}}
```
obtained from, (here only printing, made a dictionary in the implementation in the PR)
```
for j in dir(l):
    print(f'l.{j}.__qualname__')
```
this check fails for,
```
{'list': {'__doc__', '__hash__', '__class__'}}
```
I would also want these,
```
{'list': {'__instancecheck__','__subclasscheck__', '__subclasses__', 'mro'},
 'type': {'__call__', '__prepare__'}}
```
which were obtained from,
```
for j in set(dir(type(l))) - set(dir(l)):
    print(f'l.{j}.__qualname__')
```

and it fails for,
```
{'list': {'__abstractmethods__', '__base__', '__bases__', '__basicsize__', '__dict__', '__dictoffset__',
           '__flags__', '__itemsize__', '__module__', '__mro__',
           '__name__', '__qualname__', '__text_signature__', '__weakrefoffset__'}
```

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47254>
_______________________________________


More information about the Python-bugs-list mailing list