dir()は、指定されたオブジェクトの属性とそこから到達可能な属性を含むすべての名前のリストを返します
しかし、unix grepツールと同様に、単純な方法で dir() の結果を正規表現フィルタリングする機能が必要です
>>> dir(list)
['__add__', '__class__', '__contains__', ...... ,'remove', 'reverse', 'sort']
上記は属性の膨大なリストを返しますが、簡潔にするために一部を非表示にしています。
>>> # How can I do something like this, which allows me to reduce the list.
>>> dir(list,filter='<regular-expression>')
例:
>>> dir(list,'in')
['__contains__', '__init__', 'index', 'insert']
フィルタリングされたすべての要素には、属性内に「in」という式が含まれています。
python dir() 関数などを使用して、この種の正規表現ベースのフィルタリングを実現するにはどうすればよいですか?