LEFT | RIGHT |
(no file at all) | |
1 :mod:`inspect` --- Inspect live objects | 1 :mod:`inspect` --- Inspect live objects |
2 ======================================= | 2 ======================================= |
3 | 3 |
4 .. module:: inspect | 4 .. module:: inspect |
5 :synopsis: Extract information and source code from live objects. | 5 :synopsis: Extract information and source code from live objects. |
6 .. moduleauthor:: Ka-Ping Yee <ping@lfw.org> | 6 .. moduleauthor:: Ka-Ping Yee <ping@lfw.org> |
7 .. sectionauthor:: Ka-Ping Yee <ping@lfw.org> | 7 .. sectionauthor:: Ka-Ping Yee <ping@lfw.org> |
8 | 8 |
9 **Source code:** :source:`Lib/inspect.py` | 9 **Source code:** :source:`Lib/inspect.py` |
10 | 10 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 | 166 |
167 | 167 |
168 .. function:: getmembers(object[, predicate]) | 168 .. function:: getmembers(object[, predicate]) |
169 | 169 |
170 Return all the members of an object in a list of (name, value) pairs sorted b
y | 170 Return all the members of an object in a list of (name, value) pairs sorted b
y |
171 name. If the optional *predicate* argument is supplied, only members for whi
ch | 171 name. If the optional *predicate* argument is supplied, only members for whi
ch |
172 the predicate returns a true value are included. | 172 the predicate returns a true value are included. |
173 | 173 |
174 .. note:: | 174 .. note:: |
175 | 175 |
176 :func:`getmembers` does not return metaclass attributes when the argument | 176 :func:`getmembers` will only return metaclass attributes when the |
177 is a class (this behavior is inherited from the :func:`dir` function). | 177 argument is a class and those attributes have been listed in a custom |
| 178 :meth:`__dir__`. |
178 | 179 |
179 | 180 |
180 .. function:: getmoduleinfo(path) | 181 .. function:: getmoduleinfo(path) |
181 | 182 |
182 Returns a :term:`named tuple` ``ModuleInfo(name, suffix, mode, module_type)`` | 183 Returns a :term:`named tuple` ``ModuleInfo(name, suffix, mode, module_type)`` |
183 of values that describe how Python will interpret the file identified by | 184 of values that describe how Python will interpret the file identified by |
184 *path* if it is a module, or ``None`` if it would not be identified as a | 185 *path* if it is a module, or ``None`` if it would not be identified as a |
185 module. In that tuple, *name* is the name of the module without the name of | 186 module. In that tuple, *name* is the name of the module without the name of |
186 any enclosing package, *suffix* is the trailing part of the file name (which | 187 any enclosing package, *suffix* is the trailing part of the file name (which |
187 may not be a dot-delimited extension), *mode* is the :func:`open` mode that | 188 may not be a dot-delimited extension), *mode* is the :func:`open` mode that |
(...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
998 *generator* is not a Python generator object. | 999 *generator* is not a Python generator object. |
999 | 1000 |
1000 .. impl-detail:: | 1001 .. impl-detail:: |
1001 | 1002 |
1002 This function relies on the generator exposing a Python stack frame | 1003 This function relies on the generator exposing a Python stack frame |
1003 for introspection, which isn't guaranteed to be the case in all | 1004 for introspection, which isn't guaranteed to be the case in all |
1004 implementations of Python. In such cases, this function will always | 1005 implementations of Python. In such cases, this function will always |
1005 return an empty dictionary. | 1006 return an empty dictionary. |
1006 | 1007 |
1007 .. versionadded:: 3.3 | 1008 .. versionadded:: 3.3 |
LEFT | RIGHT |