On this page
  1. inspect.BoundArguments
  2. Import
  3. Signature & Overview
  4. Methods & Attributes
  5. Usage
  6. Gotchas
  7. REPL Inspect

inspect.BoundArguments

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


Import

import inspect
from inspect import BoundArguments

Signature & Overview

inspect.BoundArguments(signature, arguments)

Result of Signature.bind call. Holds the mapping of arguments to the function's parameters.

Methods & Attributes

Usage

import inspect

def greet(name: str, excited: bool = False) -> str:
    return f"hi {name}"

sig = inspect.signature(greet)
bound = sig.bind("Ada")
bound.apply_defaults()
assert isinstance(bound, inspect.BoundArguments)
assert bound.arguments == {"name": "Ada", "excited": False}

Gotchas

REPL Inspect

from inspect import BoundArguments
help(BoundArguments)

Linked from

Related notes