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

inspect.Parameter

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


Import

import inspect
from inspect import Parameter

Signature & Overview

inspect.Parameter(name, kind, *, default, annotation)

Represents a parameter in a function signature.

Methods & Attributes

Usage

import inspect

def fn(a, /, b=1, *, c=2): pass
params = inspect.signature(fn).parameters
assert params["a"].kind is inspect.Parameter.POSITIONAL_ONLY
assert params["c"].kind is inspect.Parameter.KEYWORD_ONLY
assert params["a"].default is inspect.Parameter.empty

Gotchas

REPL Inspect

from inspect import Parameter
help(Parameter)

Linked from

Related notes