aspis.common.flip
- aspis.common.flip(fn)[source]
Returns a new function much like the supplied one, except that the first two arguments’ order is reversed.
- Parameters:
fn (Callable[..., Any]) – The function to be called with the first two arguments reversed.
- Returns:
A new function that calls fn with the first two arguments reversed.
- Return type:
Callable[…, Any]
Example
>>> from aspis.common import divide >>> divide(10, 2) 5.0 >>> flip(divide)(10, 2) 0.2