I have a little function called la in my $HOME/.pythonrc.py
def la(obj, key=None, ignore_case=1):
'''List all attributes of object'''
import re
if key:
if ignore_case:
flags = re.I
else:
flags = 0
func = re.compile(key, flags).search
else:
func = None
print "\n".join(filter(func, dir(obj)))
This prints the attributes of an object one per line and also gives you the ability to search for specific items.
>>> from user import la
>>> import wx
>>> la(wx, "open")
ART_FILE_OPEN
ART_FOLDER_OPEN
EVT_MENU_OPEN
ID_OPEN
OPEN
Process_Open
wxEVT_MENU_OPEN
>>>
(Sun Aug 27 14:03:24 JDT 2006: Added regular expression to "la")
1 comment:
Added regular expression to "la"
Post a Comment