On this page
inspect.getmodule
Prev: inspect.getmembers_static | Up: inspect | Next: inspect.getmodulename
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getmodule
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getmodule
Signature & Overview
inspect.getmodule(object, _filename=None)
Return the module an object was defined in, or None if not found.
Usage
import inspect
import json
assert inspect.getmodule(json.dumps) is json
Gotchas
- Can return
Nonefor dynamically created functions or objects whose module isn't insys.modules.
REPL Inspect
from inspect import getmodule
help(getmodule)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getmembers_static Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getmodulename 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