On this page
inspect.Attribute
Prev: inspect.Arguments | Up: inspect | Next: inspect.BlockFinder
Rel: inspect.ArgInfo, inspect.Arguments, inspect.BlockFinder, inspect.BoundArguments
Ref: docs.python.org โ inspect.Attribute
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import Attribute
Signature & Overview
inspect.Attribute(name, kind, defining_class, object)
Attribute(name, kind, defining_class, object)
Methods & Attributes
Attribute.count(self, value, /)โ Return number of occurrences of value.Attribute.index(self, value, start=0, stop=9223372036854775807, /)โ Return first index of value.
Usage
import inspect
class Demo:
x = 1
def m(self): pass
attrs = {a.name: a for a in inspect.classify_class_attrs(Demo)}
assert isinstance(attrs["m"], inspect.Attribute) and attrs["m"].kind == "method"
Gotchas
- Returned by
inspect.classify_class_attrs(cls): Exposes.name,.kind,.defining_class, and.object.
REPL Inspect
from inspect import Attribute
help(Attribute)
Linked from
- tuts/python3/stdlib_module/inspect
- tuts/python3/stdlib_module/inspect/ArgInfo
- tuts/python3/stdlib_module/inspect/Arguments
- tuts/python3/stdlib_module/inspect/BlockFinder
- tuts/python3/stdlib_module/inspect/BoundArguments
- tuts/python3/stdlib_module/inspect/BufferFlags
- tuts/python3/stdlib_module/inspect/ClassFoundException
- tuts/python3/stdlib_module/inspect/classify_class_attrs
- tuts/python3/stdlib_module/inspect/cleandoc
- tuts/python3/stdlib_module/inspect/ClosureVars
- tuts/python3/stdlib_module/inspect/currentframe
- tuts/python3/stdlib_module/inspect/EndOfBlock
- tuts/python3/stdlib_module/inspect/findsource
- tuts/python3/stdlib_module/inspect/formatannotation
- tuts/python3/stdlib_module/inspect/formatannotationrelativeto
- tuts/python3/stdlib_module/inspect/formatargvalues
- tuts/python3/stdlib_module/inspect/FrameInfo
- tuts/python3/stdlib_module/inspect/FullArgSpec
- tuts/python3/stdlib_module/inspect/get_annotations
- tuts/python3/stdlib_module/inspect/getabsfile
- tuts/python3/stdlib_module/inspect/getargs
- tuts/python3/stdlib_module/inspect/getargvalues
- tuts/python3/stdlib_module/inspect/getasyncgenlocals
- tuts/python3/stdlib_module/inspect/getasyncgenstate
- tuts/python3/stdlib_module/inspect/getattr_static
- tuts/python3/stdlib_module/inspect/getblock
- tuts/python3/stdlib_module/inspect/getcallargs
- tuts/python3/stdlib_module/inspect/getclasstree
- tuts/python3/stdlib_module/inspect/getclosurevars
- tuts/python3/stdlib_module/inspect/getcomments
- tuts/python3/stdlib_module/inspect/getcoroutinelocals
- tuts/python3/stdlib_module/inspect/getcoroutinestate
- tuts/python3/stdlib_module/inspect/getdoc
- tuts/python3/stdlib_module/inspect/getfile
- tuts/python3/stdlib_module/inspect/getframeinfo
- tuts/python3/stdlib_module/inspect/getfullargspec
- tuts/python3/stdlib_module/inspect/getgeneratorlocals
- tuts/python3/stdlib_module/inspect/getgeneratorstate
- tuts/python3/stdlib_module/inspect/getinnerframes
- tuts/python3/stdlib_module/inspect/getlineno
- tuts/python3/stdlib_module/inspect/getmembers
- tuts/python3/stdlib_module/inspect/getmembers_static
- tuts/python3/stdlib_module/inspect/getmodule
- tuts/python3/stdlib_module/inspect/getmodulename
- tuts/python3/stdlib_module/inspect/getmro
- tuts/python3/stdlib_module/inspect/getouterframes
- tuts/python3/stdlib_module/inspect/Parameter
- tuts/python3/stdlib_module/inspect/Signature
- tuts/python3/stdlib_module/inspect/Traceback
Related notes
- tuts/python3/stdlib_module/inspect/ArgInfo Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/Arguments Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BlockFinder Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/BoundArguments 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/BufferFlags links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClassFoundException links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/classify_class_attrs links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/cleandoc links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/ClosureVars links to this page; shared tags: #inspect, #stdlib