Show More
@@ -48,8 +48,7 b' def dir2(obj):' | |||||
48 | """dir2(obj) -> list of strings |
|
48 | """dir2(obj) -> list of strings | |
49 |
|
49 | |||
50 | Extended version of the Python builtin dir(), which does a few extra |
|
50 | Extended version of the Python builtin dir(), which does a few extra | |
51 |
checks, and |
|
51 | checks, and handles Traits objects, which can confuse dir(). | |
52 | dir(), such as Traits and PyCrust. |
|
|||
53 |
|
52 | |||
54 | This version is guaranteed to return only a list of true strings, whereas |
|
53 | This version is guaranteed to return only a list of true strings, whereas | |
55 | dir() returns anything that objects inject into themselves, even if they |
|
54 | dir() returns anything that objects inject into themselves, even if they | |
@@ -72,10 +71,8 b' def dir2(obj):' | |||||
72 |
|
71 | |||
73 |
|
72 | |||
74 | # for objects with Enthought's traits, add trait_names() list |
|
73 | # for objects with Enthought's traits, add trait_names() list | |
75 | # for PyCrust-style, add _getAttributeNames() magic method list |
|
|||
76 | for attr in ('trait_names', '_getAttributeNames'): |
|
|||
77 |
|
|
74 | try: | |
78 |
|
|
75 | func = getattr(obj, 'trait_names') | |
79 |
|
|
76 | if callable(func): | |
80 |
|
|
77 | words |= set(func()) | |
81 |
|
|
78 | except: |
General Comments 0
You need to be logged in to leave comments.
Login now