dir() returns a list of all the names, comprising the attributes of the given object and of attributes reachable from it
But, I want the ability to regex filter the results of dir() in a simple manner, similar to the unix grep tool
>>> dir(list)
['__add__', '__class__', '__contains__', ...... ,'remove', 'reverse', 'sort']
The above returns a huge list of attributes, and some of then have been hidden for brevity.
>>> # How can I do something like this, which allows me to reduce the list.
>>> dir(list,filter='<regular-expression>')
Example:
>>> dir(list,'in')
['__contains__', '__init__', 'index', 'insert']
All the filtered elements have the attributes have the expression "in" within them.
How can I achieve this kind of regular-expression based filtering with the python dir() function or something similar?