documentation index ◦ reference manual ◦ function index

# renpy.curry

Function: | renpy.curry | (func):

Currying is an operation that allows a function to be called using a chain of calls, each providing some of the arguments. In Ren'Py, calling renpy.curry(func) returns a callable object. When this object is called with arguments, a second callable object is returned that stores func and the supplied arguments. When this second callable object is called, the original function is called with the stored arguments and the arguments supplied to the second call.

Positional arguments from the first call are placed before positional arguments from the second call. If a keyword argument is given in both calls, the value from the second call takes priority.

Curry objects can be pickled provided the original function remains available at its original name.

    init python:
         def real_add(a, b):
               return a + b

         add = renpy.curry(add)

    label start:
         $ v = add(1)
         $ result = v(2)

         # result is now 3.

documentation index ◦ reference manual ◦ function index