On this page
inspect.getabsfile
Prev: inspect.get_annotations | Up: inspect | Next: inspect.getargs
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.getabsfile
Tags: #public #python3 #stdlib #inspect
Import
import inspect
from inspect import getabsfile
Signature & Overview
inspect.getabsfile(object, _filename=None)
Return an absolute path to the source or compiled file for an object.
Usage
import inspect
import json
from pathlib import Path
path = inspect.getabsfile(json)
assert Path(path).is_absolute()
Gotchas
- Raises
TypeErrorfor built-in C modules (likesysormath) that have no Python source file.
REPL Inspect
from inspect import getabsfile
help(getabsfile)
Linked from
Related notes
- tuts/python3/stdlib_module/inspect/get_annotations Linked here; links to this page; shared tags: #inspect, #stdlib
- tuts/python3/stdlib_module/inspect/getargs 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