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

functools.partial

Prev: functools.lru_cache | Up: functools | Next: functools.partialmethod
Rel: functools.cache, functools.cached_property, functools.cmp_to_key, functools.lru_cache
Ref: docs.python.org — functools.partial
Tags: #public #python3 #stdlib #functools


Import

import functools
from functools import partial

Signature & Overview

functools.partial(func, /, *args, **keywords)

Create a new function with partial application of the given arguments and keywords.

Usage

from functools import partial

parse_hex = partial(int, base=16)
assert parse_hex("ff") == 255
assert parse_hex("10") == 16

Gotchas

REPL Inspect

from functools import partial
help(partial)

Linked from

Related notes