Fixing an Argument to Create a New Function

Partial application creates a callable by fixing one or more inputs of an existing function while leaving other inputs for later.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. Trace a conversion
  2. Decide what gets captured

Trace a conversion

A general conversion multiplying an amount by a supplied rate can fix one particular rate for a report. The resulting function receives just the amount. See parameters and arguments for which input is resolved at each stage.

Decide what gets captured

If another job changes rates, an already constructed callable may deliberately retain the earlier rate or consult shared state. A function with captured data can expose the chosen lifetime and snapshot behavior.[1]

References

  1. Python Software Foundation, Functional Programming HOWTO ↩