flip

class iteration_utilities.flip(x, /)

Class that reverses the positional arguments to a func when called.

Parameters:
funccallable

The function that should be called with the flipped (reversed) arguments.

Examples

This can be used to alter the call to a function:

>>> from iteration_utilities import flip
>>> from functools import partial
>>> flipped = flip(isinstance)
>>> isfloat = partial(flipped, float)

>>> isfloat(10)
False
>>> isfloat(11.25)
True
__call__(*args, **kwargs)

Returns func(*tuple(reversed(args)), **kwargs) using func.

func

(callable) The function with flipped arguments (readonly).

New in version 0.6.