inspect.getmembers_static
Prev: inspect.getmembers | Up: inspect | Next: inspect.getmodule
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getmembers_static
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getmembers_static
Signature & Overview
inspect.getmembers_static(object, predicate=None)
Return all members of an object as (name, value) pairs sorted by name without triggering dynamic lookup via the descriptor protocol, getattr or getattribute. Optionally, only return members that
Usage
import inspect
class Demo:
x = 10
@property
def risky(self): raise RuntimeError("do not call")
members = dict(inspect.getmembers_static(Demo()))
assert members["x"] == 10 and isinstance(members["risky"], property)
Gotchas
- Requires Python 3.11+: Uses
getattr_static()so inspecting an object never executes property getters or__getattr__.
REPL Inspect
from inspect import getmembers_static
help(getmembers_static)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getmembers Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getmodule Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect Linked here; links to this page; shared tags: #stdlib
- tuts/python3/stdlib_module/inspect/ArgInfo Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Arguments Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Attribute Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BlockFinder Linked here; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BoundArguments shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BufferFlags shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClassFoundException shared tags: #inspect, #stdlib