inspect.classify_class_attrs
Prev: inspect.ClassFoundException | Up: inspect | Next: inspect.cleandoc
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.classify_class_attrs
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import classify_class_attrs
Signature & Overview
inspect.classify_class_attrs(cls)
Return list of attribute-descriptor tuples.
Usage
import inspect
class A:
@staticmethod
def s(): pass
@classmethod
def c(cls): pass
kinds = {a.name: a.kind for a in inspect.classify_class_attrs(A)}
assert kinds["s"] == "static method" and kinds["c"] == "class method"
Gotchas
- Distinguishes
"method","class method","static method","property", and"data": Includes inherited attributes along the MRO.
REPL Inspect
from inspect import classify_class_attrs
help(classify_class_attrs)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/ClassFoundException Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/cleandoc 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/ClosureVars shared tags: #inspect, #stdlib