On this page
  1. inspect.getfile
  2. Import
  3. Signature & Overview
  4. Usage
  5. Gotchas
  6. REPL Inspect

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

REPL Inspect

from inspect import getfile
help(getfile)

Linked from

Related notes