On this page
inspect.getfile
Prev: inspect.getdoc | Up: inspect | Next: inspect.getframeinfo
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getfile
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getfile
Signature & Overview
inspect.getfile(object)
Work out which source or compiled file an object was defined in.
Usage
import inspect
import json
path = inspect.getfile(json.dumps)
assert path.endswith(".py")
Gotchas
- Raises
TypeErrorfor built-in C functions/classes (likelenorint).
REPL Inspect
from inspect import getfile
help(getfile)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/getdoc Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getframeinfo 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