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

inspect.currentframe

Prev: inspect.ClosureVars | Up: inspect | Next: inspect.EndOfBlock
Rel: inspect.ArgInfo, inspect.Arguments, inspect.Attribute, inspect.BlockFinder
Ref: docs.python.org — inspect.currentframe
Tags: #public #python3 #stdlib #inspect


Import

import inspect
from inspect import currentframe

Signature & Overview

inspect.currentframe()

Return the frame of the caller or None if this is not possible.

Usage

import inspect

frame = inspect.currentframe()
try:
    assert frame is not None and frame.f_lineno > 0
finally:
    del frame   # avoid keeping reference cycles alive

Gotchas

REPL Inspect

from inspect import currentframe
help(currentframe)

Linked from

Related notes