inspect.getcoroutinelocals
Prev: inspect.getcomments | Up: inspect | Next: inspect.getcoroutinestate
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getcoroutinelocals
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getcoroutinelocals
Signature & Overview
inspect.getcoroutinelocals(coroutine)
Get the mapping of coroutine local variables to their current values.
Usage
import inspect
async def job(x: int):
return x
c = job(7)
try:
assert inspect.getcoroutinelocals(c) == {"x": 7}
finally:
c.close()
Gotchas
- Always
.close()unawaited coroutines in tests to avoidRuntimeWarning.
REPL Inspect
from inspect import getcoroutinelocals
help(getcoroutinelocals)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getcomments Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getcoroutinestate 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